Skip to content

Allow UTF-8 emoji characters in NINJA_STATUS#2727

Open
jthackray wants to merge 1 commit intoninja-build:masterfrom
jthackray:master
Open

Allow UTF-8 emoji characters in NINJA_STATUS#2727
jthackray wants to merge 1 commit intoninja-build:masterfrom
jthackray:master

Conversation

@jthackray
Copy link

@jthackray jthackray commented Feb 11, 2026

Add UTF-8 parsing code to allow UTF-8 encoded emojis in NINJA_STATUS. In #2428, support was added for parsing ANSI colors, so that the correct terminal width was observed. This patch is similar in nature, and allows UTF-8 emojis to be used whilst still using the full width of the terminal window.

I've had to add quite a bit of UTF-8 parsing code, so we don't misparse UTF-8 glyphs. ElideMiddle now decodes UTF-8 codepoints and assigns terminal column widths with a small emoji-width heuristic, while treating ZWJ and variation selectors as zero-width.

This code assumes common emoji and pictograph ranges render as double-width and everything else is single-width unless it is a control character. I would use wcwidth(), but AFAIK, this isn't available on Windows.

I've added some new tests for this functionality, and all the existing tests continue to pass.

Fixes #2728

Add UTF-8 parsing code to allow UTF-8 encoded emojis in
NINJA_STATUS. In ninja-build#2428, support was adding for parsing ANSI
colors, so that the correct terminal width was observed. This
patch is similar in nature, and allows UTF-8 emojis to be used
whilst still using the full width of the terminal window.

I've had to add quite a bit of UTF-8 parsing code, so we don't misparse
the UTF-8 glyph. ElideMiddle now decodes UTF-8 codepoints and assigns
terminal column widths with a small emoji-width heuristic, while treating
ZWJ and variation selectors as zero-width.

This code assumes common emoji and pictograph ranges render as double-width
and everything else is single-width unless it is a control character. I would
use wcwidth(), but AFAIK, this isn't available on Windows.

I've added some new tests for this functionality, and all the
existing tests continue to pass.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support UTF-8 encoded emojis in NINJA_STATUS environment variable

1 participant