Allow UTF-8 emoji characters in NINJA_STATUS#2727
Open
jthackray wants to merge 1 commit intoninja-build:masterfrom
Open
Allow UTF-8 emoji characters in NINJA_STATUS#2727jthackray wants to merge 1 commit intoninja-build:masterfrom
jthackray wants to merge 1 commit intoninja-build:masterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
ElideMiddlenow 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