You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15, U+FE0E? #211
changed the title [-]Should wcswidth return 2 for text-style of an emoji character?[/-][+]Should wcswidth return 2 for text-style of an emoji character? (VS-15, U+FE0E[/+]on Mar 28, 2026
When the previous cell has width two and the last code point in the previous cell is one of the Basic_Emoji code points from the Wide emoji rule above that is not followed by U+FE0Fthen the width of the previous cell is decreased to one.
And I think VS-15 serves to fulfill the need to display normally Wide emojis in a matching size and bitonal color, of only these select few early emojis, as if to show it in its historical or simplified form. I believe VS-15 exists for a mirrored property, that turning a Wide emoji into text display makes it Narrow (VS15), just as making text into emoji presentation makes it wide(VS16).
And at one time the East Asian Width spec specifically mentioned VS-16 making narrow characters wide (but said nothing about VS-15 making wide characters narrow).
Aside from the practicality, the fact that TR-11 was so explicit about the VS-16 making glyphs wider, while having no mention of VS-15 making glyphs narrow, is (I think) what convinced most terminal devs that VS-15 should only affect the visual appearance, and not the width.
It's not like this topic hasn't been discussed before. It's just that almost everyone has already agreed on the correct behavior. That's why you're seeing the results you're seeing in your tests.
changed the title [-]Should wcswidth return 2 for text-style of an emoji character? (VS-15, U+FE0E[/-][+]Should wcswidth return Narrow for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/+]on Mar 28, 2026
I renamed your title to be more clear, please check, that:
>>>wcwidth.wcswidth("\N{WHITE HEAVY CHECK MARK}\N{VARIATION SELECTOR-15}")
2
wcswidth() measures this as a "wide character" (2 cells), which matches a majority of terminals, but, in kitty, this is displayed as "narrow" (one cell).
I do agree the correct interpretation of the specification should return 1 instead of 2, but python wcwidth as it is currently published returns 2.
changed the title [-]Should wcswidth return Narrow for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/-][+]Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/+]on Mar 28, 2026
changed the title [-]Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/-][+]Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15, U+FE0E?[/+]on Mar 28, 2026
Yes, returned cell width for "\N{WHITE HEAVY CHECK MARK}\N{VARIATION SELECTOR-15}" is 2, not 1.
I didn't realise that Kitty is alone in this interpretation, I thought it would be the more common one.
I don't think there's really anything better to do in wcwidth then and this should just be closed.
Thanks for a detailed response with all the references!
Yes, Kovid and I may be wrong about the interpretation of the unicode.org standard.. it's not really our fault, the for-pay membership unicode technical committee makes little to no effort to specify any concern for fixed-width/monospace rules, so they leave a lot up for interpretation.
In these cases, this library aims to be most compatible with a majority of "progressive" or "actively developed" terminals. kitty is certainly one of the best, ranking number 2 in ucs-detect results which includes matching the specification of python wcwidth, (after ghostty, number one, which also appears to agree to display these characters Narrow by my testing).
But, they are also alone in this regard, only 2 out of 35 terminals tested match this behavior right now. note that my testing reads "python wcwidth.wcswidth() measures width 1, while [...] measures width 2.", but this statement is false, I need to update this documentation to reflect this specific "VS-15" automatic testing does not match current released python wcwidth behavior, it's tricky to describe because of this fence sitting.
I have updated ucs-detect report to reference this issue,
The interpretation of VS-15 (U+FE0E) narrowing Wide Emoji is contested. While this test expects VS-15 to make Wide Emoji Narrow, most terminal emulators do not implement this behavior, and python wcwidth.wcswidth() does not currently return a narrow width for these sequences. Only 2 of 35 terminals tested match this expectation. This score is excluded from the final ranking. See jquast/wcwidth#211.
So I will leave this issue open, anyway. I can certainly be persuaded to match kitty and ghostty, as these terminal authors are very progressive and thoughtful about their implementation compared to the other terminal authors.
If you think an emoji followed by VS-15 should have a width of 1, here's a little test for you to run.
importsyscheck='\u2705'check_vs15=check+'\uFE0E'sys.stdout.write('<--------20-------->\n')
sys.stdout.write('\033[4h') # enable insert mode sys.stdout.write('*'*10) # write 10 asteriskssys.stdout.write('\r') # return to start of linesys.stdout.write(check*5) # insert 5 check markssys.stdout.write('\n') # move to new linesys.stdout.write('*'*10) # write 10 asteriskssys.stdout.write('\r') # return to start of linesys.stdout.write(check_vs15*5) # insert 5 check marks with VS-15sys.stdout.write('\n') # move to new linesys.stdout.write('\033[4l') # back to replace modesys.stdout.write('<-----15------>\n')
In the code above, we're writing out 10 asterisks, then inserting 5 emojis at the start of the same line using IRM. For the first attempt, the emojis have no VS-15 suffix, and in the second attempt, each emoji is followed by a VS-15 suffix.
If VS-15 makes the emoji narrow, then the first line should span 20 columns, and the second line should only span 15 columns.
As for IRM behavior, you are correct that you predicted this misbehaving insert mode with a wide-to-narrow VS-15, wcwidth so far does not interpret this sequence (and I don't think it should)
Yeah, I just came here to post an updated screenshot. My original test was on an older version. But the fundamental problem still remains. Neither of those terminals are consistently handling VS-15 characters as 1 cell wide, and any application assuming that is going to break.
Btw, here's another scenario for you. Imagine you're writing an editor, and you've determined that the terminal screen width is w, if wcswidth reports a string's width to be w, is it safe to assume you can fit that string on one line without wrapping?
With a terminal width of 40, I can fit 40 asterisks on one line, so if a VS-15 check mark is also 1 cell wide, I should also be able to fit 40 check marks on one line, right?
Here's Ghostty:
And here's Kitty:
Do you honestly still think that these are the only terminals that have got VS-15 right, and everyone else has got it wrong?
Yup, iter_graphemes is what's needed. I am busy right now but a little
later I'll give you a function that can be used to output a list of
graphemes to the terminal so that it works even when the last grapheme
is a narrowed by VS15 one (the case @j4james was talking about above).
That way any application can output lines of text to the terminal robustly
regardless of use of VS15 to narrow.
On Sun, Mar 29, 2026 at 07:20:36AM -0700, James Holderness wrote:
j4james left a comment (jquast/wcwidth#211)
> The standard also says the TEXT PRESENTATION characters should be narrow unless otherwise specified in EastAsianWidth.
I'm willing to accept that this is something I've overlooked in the standard, but when I asked you to quote the relevant text, you refused, saying that "the Unicode standard does not say much of anything about how text should be mapped to a fixed width grid".
UAX 11 (not bothering to link it here am sure you know where to find
it) assign 5 categories to all code points. Wide, narrow, full width,
ambiguous and neutral. Then in ED4 it says:
East Asian Wide (W): All other characters that are always wide. These characters occur only in the context of East Asian typography where they are wide characters (such as the Unified Han Ideographs or Squared Katakana Symbols). This category includes characters that have explicit halfwidth counterparts, along with characters that have the [UTS51] property Emoji_Presentation, with the exception of characters that have the [UCD] property Regional_Indicator
Note in particular the part about Emoji_Presentation.
You then went on to say that it could be *implied* based on the following claim:
> All emoji presentation codepoints are rendered in two cells and all text presentation code points are rendered in one cell *unless their width is set to two* in EastAsianWidth.txt from the standard.
But that statement isn't actually true. For example, the regional indicator symbols have the **Emoji_Presentation** property, but have a width of 1 (EastAsianWidth.txt assigns them a neutral width, which the standard recommends should be treated as narrow).
The difference is that the standard explicitly stated that VS-16 should make a codepoint wide, regardless of the original assigned width. See here:
https://www.unicode.org/reports/tr11/tr11-41.html#Recommendations
> [UTS51] emoji presentation sequences behave as though they were East Asian Wide, regardless of their assigned East_Asian_Width property value.
That line was removed in later revisions, but that was the reason why many terminals considered it a reasonable choice to make back when this was first discussed. There was no mention of text presentation sequences having any effect on the assigned width.
It's still there in ED4 as I linked to above. To me it is trivially
obvious when it says that Emoji presentation is expicitly wide it
implies text presentation (modulo corner cases specified elsewhere) is
narrow.
As promised, here is a function that takes an iterator over graphemes
and writes it to the terminal in no more than wcswidth() cells so that
it does not suffer from an unpredictability of behavior. It uses only
classic terminal escape codes to do it. As long as the code used to
split into graphemes and the terminals code ot split into graphemes
match, this is 100% deterministic when you use it to output text one
screen line at a time. Of course, it's better to use the text sizing
protocol, but this is a useful stopgap until that is more widely
adopted.
classGrapheme:
text: strwidth: int=1defoutput_in_wcswidth(iterator_over_graphemes):
' Output graphemes so that they affect exactly wcswidth cells only (works for >= 2 graphmes) 'graphemes=tuple(iterator_over_graphemes)
ifnotgraphemes:
returnyieldgraphemes[0].textforiinrange(1, len(graphemes)):
g=graphemes[i]
ifgisgraphemes[-1]:
prev_g=graphemes[i-1]
yieldf'\x1b[{prev_g.width}D'# move cursor back]yieldg.textyieldf'\x1b[{g.width}D'# move cursor back]yieldf'\x1b[{prev_g.width}@'# insert cells]yieldprev_g.textyieldf'\x1b[{g.width}C'# move cursor forward]
Then in ED7: "ED7. Neutral (Not East Asian): All other characters. Neutral characters do not occur in legacy East Asian character sets. By extension, they also do not tend to occur in East Asian typography. For example, there is no traditional Japanese way of typesetting Devanagari. Canonical equivalents of narrow and neutral characters may not themselves be narrow or neutral respectively. For example, U+00C5 Å LATIN CAPITAL LETTER A WITH RING ABOVE is Neutral, but its decomposition starts with a Narrow character.
Strictly speaking, it makes no sense to talk of narrow and wide for neutral characters, but because for all practical purposes they behave like Na, they are treated as narrow characters (the same as Na) under the recommendations below.
In a broad sense, wide characters include W, F, and A (when in East Asian context), and narrow characters include N, Na, H, and A (when not in East Asian context)."
And I have spent as much time on this as I care too. It's both patently obvious and in the standard above that text presentation characters should be narrow. And it is in the standard in UTS51 that VS15 changes the presentation to text from emoji when the base character has emoji presentation. It is as simple as that. Good luck. I am done repeating myself.
The TLDR: ED4 says Emoji_presentation characters have W class aka width 2. ED5 and ED7 say all Na and A codepoints have narrow width. ED4 is what makes emoji have W=2 when they have emoji presentation. Once an emoji is changed to text presentation, ED4 does not apply. Then ED5 and ED7 apply. Hence it has width=1
Ambiguous characters behave like wide or narrow characters depending on the context (language tag, script identification, associated font, source of data, or explicit markup; all can provide the context). If the context cannot be established reliably, they should be treated as narrow characters by default.
none of ED4, ED5, or ED7 make those characters cease being classed as W when given text_presentation, they are still emoji_presentation characters, even when their text presentation has been requested by a following variation selector.
If you want to say this is ambiguous or underspecified, then the next answer is to check the available context. In the case of a terminal with a font for rendering, this would obviously just be checking the font's width for that character in text presentation.
This is something that probably should be cleared up more in the specification, but having the ability to give wcwidth the font currently in use to use for context would allow such situations to be inline with what users actually see rendered.
With regard to the associated issue over on the terminal side, I don't think most apps have a good way to solve this (ask for the font and other context) with the current standards and protocols, but I'd love to be wrong about that.
I don't think most apps have a good way to solve this (ask for the font and other context) with the current standards and protocols, but I'd love to be wrong about that.
@mikeshardmind This was the reason Contour proposed the terminal-unicode-core spec, and why it has a mode which applications can query to determine whether a particular terminal is following that spec. Regardless of how different people may interpret the wording of the Unicode standard, if a terminal reports that it is following the terminal-unicode-core spec, then apps should be able to rely on that terminal rendering a sequence of glyphs with a predictable width (at least in a perfect world in which nobody has any bugs).
In theory, a CLI program can query this mode to classify a terminal as "reasonably supporting" unicode, but not which specific features or version level. Since other terminals with similar capabilities do not respond to Mode 2027 queries, this binary indicator has limited utility.
The only practical approach to determining Unicode support of a terminal is to interactively test for specific features, codepoints, and at the Unicode version levels of interest, as ucs-detect does.
Next release of wcwidth.wcswidth() will return Narrow (1) for Basic Emojis followed by VS-15.
This is because new function, wcstwidth() can be used to provide measurement corrections:
>>>text_emoji="\N{WHITE HEAVY CHECK MARK}\N{VARIATION SELECTOR-15}">>>wcwidth.wcswidth(text_emoji) # vs-15 is now narrow by default1>>># get measurement with possible correction applied by process TERM_PROGRAM or TERM (ghostty)wcwidth.wcstwidth(text_emoji)
1>>># get "corrected" width for contour terminal,>>>wcwidth.wcstwidth(text_emoji, term_program='contour')
2
Activity
[-]Should wcswidth return 2 for text-style of an emoji character?[/-][+]Should wcswidth return 2 for text-style of an emoji character? (VS-15, U+FE0E[/+]jquast commentedon Mar 28, 2026
Yes @Jackenmen, actually I do agree with Kovid Goyal's specification,
I independently came to the same conclusion, my remarks from analysis last year
This analysis was done in response to @j4james' criticism on HN,
I asked @j4james to review, responding,
And so the matter was closed and not published.
[-]Should wcswidth return 2 for text-style of an emoji character? (VS-15, U+FE0E[/-][+]Should wcswidth return Narrow for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/+]jquast commentedon Mar 28, 2026
I renamed your title to be more clear, please check, that:
wcswidth() measures this as a "wide character" (2 cells), which matches a majority of terminals, but, in kitty, this is displayed as "narrow" (one cell).
I do agree the correct interpretation of the specification should return 1 instead of 2, but python wcwidth as it is currently published returns 2.
Happy to have any further feedback.
[-]Should wcswidth return Narrow for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/-][+]Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/+][-]Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15? (VS-15, U+FE0E[/-][+]Should wcswidth return Narrow (1) for Basic Emojis followed by VS-15, U+FE0E?[/+]Jackenmen commentedon Mar 28, 2026
Yes, returned cell width for
"\N{WHITE HEAVY CHECK MARK}\N{VARIATION SELECTOR-15}"is 2, not 1.I didn't realise that Kitty is alone in this interpretation, I thought it would be the more common one.
I don't think there's really anything better to do in wcwidth then and this should just be closed.
Thanks for a detailed response with all the references!
jquast commentedon Mar 28, 2026
Your welcome!
Yes, Kovid and I may be wrong about the interpretation of the unicode.org standard.. it's not really our fault, the for-pay membership unicode technical committee makes little to no effort to specify any concern for fixed-width/monospace rules, so they leave a lot up for interpretation.
In these cases, this library aims to be most compatible with a majority of "progressive" or "actively developed" terminals. kitty is certainly one of the best, ranking number 2 in ucs-detect results which includes matching the specification of python wcwidth, (after ghostty, number one, which also appears to agree to display these characters Narrow by my testing).
But, they are also alone in this regard, only 2 out of 35 terminals tested match this behavior right now.
note that my testing reads "python wcwidth.wcswidth() measures width 1, while [...] measures width 2.", but this statement is false, I need to update this documentation to reflect this specific "VS-15" automatic testing does not match current released python wcwidth behavior, it's tricky to describe because of this fence sitting.I have updated ucs-detect report to reference this issue,
So I will leave this issue open, anyway. I can certainly be persuaded to match kitty and ghostty, as these terminal authors are very progressive and thoughtful about their implementation compared to the other terminal authors.
jquast commentedon Mar 28, 2026
An issue where @j4james persuaded @christianparpart against implementing VS-15/U+FE0E in Contour terminal, contour-terminal/contour#404 (comment)
j4james commentedon Mar 28, 2026
If you think an emoji followed by VS-15 should have a width of 1, here's a little test for you to run.
In the code above, we're writing out 10 asterisks, then inserting 5 emojis at the start of the same line using
IRM. For the first attempt, the emojis have no VS-15 suffix, and in the second attempt, each emoji is followed by a VS-15 suffix.If VS-15 makes the emoji narrow, then the first line should span 20 columns, and the second line should only span 15 columns.
Here's what it looks like in Ghostty:

And here's what it looks like in Kitty:

Make of that what you will.
jquast commentedon Mar 29, 2026
We mismatch on ghostty, versions 1.3.0-main+4b7a55a50 (Feb 26), and 1.3.2-main+4903e2821 (today) appear as:
Which includes key VS-15 related PR's, ghostty-org/ghostty#9678 and ghostty-org/ghostty#9679 (Nov 24)
As for IRM behavior, you are correct that you predicted this misbehaving insert mode with a wide-to-narrow VS-15, wcwidth so far does not interpret this sequence (and I don't think it should)
j4james commentedon Mar 29, 2026
Yeah, I just came here to post an updated screenshot. My original test was on an older version. But the fundamental problem still remains. Neither of those terminals are consistently handling VS-15 characters as 1 cell wide, and any application assuming that is going to break.
j4james commentedon Mar 29, 2026
Btw, here's another scenario for you. Imagine you're writing an editor, and you've determined that the terminal screen width is
w, ifwcswidthreports a string's width to bew, is it safe to assume you can fit that string on one line without wrapping?Test case:
With a terminal width of 40, I can fit 40 asterisks on one line, so if a VS-15 check mark is also 1 cell wide, I should also be able to fit 40 check marks on one line, right?
Here's Ghostty:

And here's Kitty:

Do you honestly still think that these are the only terminals that have got VS-15 right, and everyone else has got it wrong?
10 remaining items
kovidgoyal commentedon Mar 29, 2026
kovidgoyal commentedon Mar 29, 2026
kovidgoyal commentedon Mar 29, 2026
As promised, here is a function that takes an iterator over graphemes
and writes it to the terminal in no more than wcswidth() cells so that
it does not suffer from an unpredictability of behavior. It uses only
classic terminal escape codes to do it. As long as the code used to
split into graphemes and the terminals code ot split into graphemes
match, this is 100% deterministic when you use it to output text one
screen line at a time. Of course, it's better to use the text sizing
protocol, but this is a useful stopgap until that is more widely
adopted.
kovidgoyal commentedon Mar 29, 2026
@j4james read http://www.unicode.org/reports/tr11/#ED5 East Asian "Narrow (Na): All other characters that are always narrow and have explicit fullwidth or wide counterparts. These characters are implicitly narrow in East Asian typography and legacy character sets because they have explicit fullwidth or wide counterparts. All of ASCII is an example of East Asian Narrow characters."
Then in ED7: "ED7. Neutral (Not East Asian): All other characters. Neutral characters do not occur in legacy East Asian character sets. By extension, they also do not tend to occur in East Asian typography. For example, there is no traditional Japanese way of typesetting Devanagari. Canonical equivalents of narrow and neutral characters may not themselves be narrow or neutral respectively. For example, U+00C5 Å LATIN CAPITAL LETTER A WITH RING ABOVE is Neutral, but its decomposition starts with a Narrow character.
Strictly speaking, it makes no sense to talk of narrow and wide for neutral characters, but because for all practical purposes they behave like Na, they are treated as narrow characters (the same as Na) under the recommendations below.
In a broad sense, wide characters include W, F, and A (when in East Asian context), and narrow characters include N, Na, H, and A (when not in East Asian context)."
And I have spent as much time on this as I care too. It's both patently obvious and in the standard above that text presentation characters should be narrow. And it is in the standard in UTS51 that VS15 changes the presentation to text from emoji when the base character has emoji presentation. It is as simple as that. Good luck. I am done repeating myself.
kovidgoyal commentedon Mar 29, 2026
The TLDR: ED4 says Emoji_presentation characters have W class aka width 2. ED5 and ED7 say all Na and A codepoints have narrow width. ED4 is what makes emoji have W=2 when they have emoji presentation. Once an emoji is changed to text presentation, ED4 does not apply. Then ED5 and ED7 apply. Hence it has width=1
mikeshardmind commentedon Mar 29, 2026
tr11 has the following to say:
none of ED4, ED5, or ED7 make those characters cease being classed as W when given text_presentation, they are still emoji_presentation characters, even when their text presentation has been requested by a following variation selector.
If you want to say this is ambiguous or underspecified, then the next answer is to check the available context. In the case of a terminal with a font for rendering, this would obviously just be checking the font's width for that character in text presentation.
This is something that probably should be cleared up more in the specification, but having the ability to give wcwidth the font currently in use to use for context would allow such situations to be inline with what users actually see rendered.
With regard to the associated issue over on the terminal side, I don't think most apps have a good way to solve this (ask for the font and other context) with the current standards and protocols, but I'd love to be wrong about that.
j4james commentedon Mar 29, 2026
@mikeshardmind This was the reason Contour proposed the terminal-unicode-core spec, and why it has a mode which applications can query to determine whether a particular terminal is following that spec. Regardless of how different people may interpret the wording of the Unicode standard, if a terminal reports that it is following the terminal-unicode-core spec, then apps should be able to rely on that terminal rendering a sequence of glyphs with a predictable width (at least in a perfect world in which nobody has any bugs).
jquast commentedon Mar 29, 2026
On Mode 2027
Terminal software identity-assisted wcswidth() (#220)
jquast commentedon Jun 5, 2026
Next release of
wcwidth.wcswidth()will return Narrow (1) for Basic Emojis followed by VS-15.This is because new function, wcstwidth() can be used to provide measurement corrections:
Note about VS15 in the specification is contested