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
What character are they disagreeing on, and what answer is utf8proc giving vs towupper? We probably should modify that error message to print a bit more info.
I'm confused, it looks like the error message is saying that utf8proc_toupper(0x00df) is giving 0x00df, which is not what utf8proc gives on my system (or yours, since Julia calls it).
Whether "ẞ" or "SS" is preferred is subject to cultural considerations, but the C locale system cannot represent the latter mapping. "ß" is obviously not a correct uppercase form for "ß".
It's been a while since I delved into the Unicode stability policy, but my understanding is that they can't (by their own policy) add new case mappings for characters that previously lacked them; even if that's wrong, they may want to avoid adding a nominal case mapping to a single character when the mapping to a sequence "SS" may be preferred in some cultures. I don't think these considerations detract from mapping to "ẞ" being the right thing to do in the limitations of the C locale framework.
musl's definitions are derived programmatically from EastAsianWidth.txt from Unicode 10.0, and I don't see any emoji marked as wide in it. Aside from actual ideographic characters, the only characters I'm aware of which are marked full/wide are the ones present in legacy charsets.
Well it says they're classified as such, and in fact the ones with Emoji_Presentation are in EastAsianWidth.txt so they should already be marked wcwidth=2 in musl. I don't know why I didn't notice them before. I think that omits a lot of characters I thought of as "emoji" including classic dingbats etc.
Until then, musl (and afaik, also glibc) take a simple approach and assign width=1 to everything except to characters that were explicitly wide in legacy CJK charsets.
Indeed, the width mismatches on Alpine stem from Alpine treating a lot of things as wcwidth 1 where we treat them as 0, 1, or 2 (from a quick skim over the sea of output).
I don't believe it's the case with glibc though; I get no mismatches running make check on Ubuntu. Unless I'm misunderstanding what you mean.
U+00ad is a soft hyphen, which is an interesting case. In some contexts it is used as a hyphenation hint and is not displayed, and in other cases it is displayed. Many terminal environments do display it, but this is not required.
U+0380 and several of the other characters are unassigned code points. It's not at all obvious what width we should use for these. I suppose, from a probabilistic standpoint, an unassigned codepoint is probably more likely to be used for a width-1 character (e.g. a private encoding like Conscript) than a width-0 character. Also, the replacement character u+fffd has width 1.
U+0601 certainly doesn't look like zero width, and isn't rendered as zero width by any font that I have (e.g. ab).
I don't know the situation with U+0601. It's probably a case of needing a special-casing. Unicode class Cf is a mess of inconsistency, and while most of them are nonspacing marks or printable formatting controls, apparently some are spacing characters too. U+00AD is already handled specially here (by historical practice it's spacing in charcell terminals, which is what wcwidth is accounting for) and U+0601 probably should be too. I don't know what evidence there is for treating it as wcwidth=2 though. That brings us back to the need for some organized review effort.
Note that there already is an "organized review effort, outside of any single software project", sponsored by the GNU project, carried out by both language and typography experts, to identify standards-conformant terminal-compatible font metrics and glyphs for the entirety of Unicode. The result is called GNU Unifont, and it is updated every time Unicode is updated.
The problem is not a lack of data or a lack of review, but rather it is the xkcd standards problem of getting everyone, up and down the stack, to agree on which data to use.
I was not aware of any such aspect to the GNU Unifont project, and wasn't even aware that it's still maintained. If it's really trying to act as a standards process for character-cell metrics, that sounds great, but there seems to be a serious lack of publicity around it. I can't even find anything supporting that claim on their website. Last I looked at it, the glyphs for many scripts were not actually usable for writing using them, and many were double-width just because it turned out to be easier to draw something nice looking in 16x16 than 8x16 for certain characters.
Their release notes make it pretty clear that Unifont is actively maintained (and is promptly updated every time Unicode is updated); I'm not sure why you would think otherwise. It is targeted especially at low-resolution displays, it's true, but that is precisely the situation most appropriate for terminals (which often use the minimum readable font size).
As for trying to act as a "standards process", now you're raising the bar. That requires buy-in from libc maintainers, who currently seem to be rejecting out-of-hand any attempt to go beyond EastAsianWidth.txt for glyph metrics.
was specifically about acting as a "standards process" with buy-in from implementors (wcwidth implementors being libc, also terminals, screen/tmux, etc.). I am not rejecting attempts to define a better wcwidth out-of-hand. I'm rejecting attempts to claim that unilateral decisions by a party with almost no stake and almost no input from users of the affected scripts should be a basis for our decisions.
a party with almost no stake and almost no input from users of the affected scripts
I'm not sure this is an accurate description of the Unifont developers.
Anyway, though we don't use it as the sole basis of our decisions, it seems like a more reasonable starting point than "all characters have width 1", which employs no input at all from users of the affected scripts.
Reasonable people can disagree about this, of course, but I don't think it's completely crazy for us to incorporate data from Unifont in determining charwidth for cases that are ambiguous in the Unicode standard.
By the way, regarding emoji being width 2, the lack of recognition of this prior to Unicode 9 led to this amusing issue in Julia that directly led to our attempt to get better charwidth tables: JuliaLang/julia#3721
Activity
stevengj commentedon Apr 19, 2018
Is this our bug our a bug in Alpine Linux?
ararslan commentedon Apr 19, 2018
Unclear and I'm not sure how to figure it out, so I figured I'd open an issue here to see if anyone had any ideas.
stevengj commentedon Apr 19, 2018
What character are they disagreeing on, and what answer is utf8proc giving vs
towupper? We probably should modify that error message to print a bit more info.ararslan commentedon Apr 19, 2018
The error message is saying
df != towupper(df) == 1e9e, so plugging that into Julia:stevengj commentedon Apr 19, 2018
I'm confused, it looks like the error message is saying that
utf8proc_toupper(0x00df)is giving0x00df, which is not what utf8proc gives on my system (or yours, since Julia calls it).ararslan commentedon Apr 19, 2018
Sure enough:
Output on Ubuntu:
Output on Alpine:
And yet,
on both systems.
ararslan commentedon Apr 19, 2018
So I guess it's Alpine's fault for returning a bogus value from
towupper.ararslan commentedon Apr 19, 2018
cc @jirutka, maintainer of the utf8proc Alpine port, and @fabled, who maintains the musl-dev port (which contains, among other things,
wctype.h).ararslan commentedon Apr 19, 2018
Since this isn't a utf8proc issue, I'll close this. Thanks for humoring me, Steven. 😉
stevengj commentedon Apr 19, 2018
Unless the uppercase mapping of U+00df changed in Unicode 10 (since utf8proc currently uses the Unicode 9 tables)?
This U+00df page says that U+1E9E is a "nonstandard uppercase," though.
fabled commentedon Apr 20, 2018
cc @richfelker
richfelker commentedon Apr 20, 2018
Regarding case mappings, this is intentional, not a bug:
https://git.musl-libc.org/cgit/musl/commit/src/ctype/towctrans.c?id=4674809bdf7a46041ac0152eea0a6363ceeca548
For wcwidth, I'd have to see what the mismatches are.
stevengj commentedon Apr 20, 2018
I agree that there is an argument for supporting the nonstandard uppercase form here.
richfelker commentedon Apr 20, 2018
Whether "ẞ" or "SS" is preferred is subject to cultural considerations, but the C locale system cannot represent the latter mapping. "ß" is obviously not a correct uppercase form for "ß".
It's been a while since I delved into the Unicode stability policy, but my understanding is that they can't (by their own policy) add new case mappings for characters that previously lacked them; even if that's wrong, they may want to avoid adding a nominal case mapping to a single character when the mapping to a sequence "SS" may be preferred in some cultures. I don't think these considerations detract from mapping to "ẞ" being the right thing to do in the limitations of the C locale framework.
5 remaining items
richfelker commentedon May 2, 2018
musl's definitions are derived programmatically from EastAsianWidth.txt from Unicode 10.0, and I don't see any emoji marked as wide in it. Aside from actual ideographic characters, the only characters I'm aware of which are marked full/wide are the ones present in legacy charsets.
stevengj commentedon May 2, 2018
https://www.unicode.org/reports/tr11/tr11-31.html#ED4 says that characters with the property
Emoji_Presentationshould be treated asEast Asian Widerichfelker commentedon May 2, 2018
Well it says they're classified as such, and in fact the ones with
Emoji_Presentationare inEastAsianWidth.txtso they should already be marked wcwidth=2 in musl. I don't know why I didn't notice them before. I think that omits a lot of characters I thought of as "emoji" including classic dingbats etc.ararslan commentedon May 2, 2018
Indeed, the width mismatches on Alpine stem from Alpine treating a lot of things as
wcwidth1 where we treat them as 0, 1, or 2 (from a quick skim over the sea of output).I don't believe it's the case with glibc though; I get no mismatches running
make checkon Ubuntu. Unless I'm misunderstanding what you mean.stevengj commentedon May 2, 2018
@ararslan, can you give an example of a character we assign width 0 where musl gives
wcwidth > 0?ararslan commentedon May 2, 2018
The full list of mismatches, all 340,000+ lines, is here: https://gist.github.com/ararslan/c7dfbfb0f9dff42940a394c79be0afe3
Taking the first few entries from there:
It looks like musl assigns width 1 to unassigned code points.
ararslan commentedon May 2, 2018
This is an interesting example where musl gives 0 and we give 2:
stevengj commentedon May 2, 2018
U+00ad is a soft hyphen, which is an interesting case. In some contexts it is used as a hyphenation hint and is not displayed, and in other cases it is displayed. Many terminal environments do display it, but this is not required.
U+0380 and several of the other characters are unassigned code points. It's not at all obvious what width we should use for these. I suppose, from a probabilistic standpoint, an unassigned codepoint is probably more likely to be used for a width-1 character (e.g. a private encoding like Conscript) than a width-0 character. Also, the replacement character u+fffd has width 1.
U+0601 certainly doesn't look like zero width, and isn't rendered as zero width by any font that I have (e.g. ab).
richfelker commentedon May 2, 2018
I don't know the situation with U+0601. It's probably a case of needing a special-casing. Unicode class Cf is a mess of inconsistency, and while most of them are nonspacing marks or printable formatting controls, apparently some are spacing characters too. U+00AD is already handled specially here (by historical practice it's spacing in charcell terminals, which is what wcwidth is accounting for) and U+0601 probably should be too. I don't know what evidence there is for treating it as wcwidth=2 though. That brings us back to the need for some organized review effort.
stevengj commentedon May 3, 2018
Note that there already is an "organized review effort, outside of any single software project", sponsored by the GNU project, carried out by both language and typography experts, to identify standards-conformant terminal-compatible font metrics and glyphs for the entirety of Unicode. The result is called GNU Unifont, and it is updated every time Unicode is updated.
The problem is not a lack of data or a lack of review, but rather it is the xkcd standards problem of getting everyone, up and down the stack, to agree on which data to use.
richfelker commentedon May 3, 2018
I was not aware of any such aspect to the GNU Unifont project, and wasn't even aware that it's still maintained. If it's really trying to act as a standards process for character-cell metrics, that sounds great, but there seems to be a serious lack of publicity around it. I can't even find anything supporting that claim on their website. Last I looked at it, the glyphs for many scripts were not actually usable for writing using them, and many were double-width just because it turned out to be easier to draw something nice looking in 16x16 than 8x16 for certain characters.
stevengj commentedon May 3, 2018
Their release notes make it pretty clear that Unifont is actively maintained (and is promptly updated every time Unicode is updated); I'm not sure why you would think otherwise. It is targeted especially at low-resolution displays, it's true, but that is precisely the situation most appropriate for terminals (which often use the minimum readable font size).
As for trying to act as a "standards process", now you're raising the bar. That requires buy-in from libc maintainers, who currently seem to be rejecting out-of-hand any attempt to go beyond EastAsianWidth.txt for glyph metrics.
richfelker commentedon May 3, 2018
The above comment that started this:
#127 (comment)
was specifically about acting as a "standards process" with buy-in from implementors (wcwidth implementors being libc, also terminals, screen/tmux, etc.). I am not rejecting attempts to define a better wcwidth out-of-hand. I'm rejecting attempts to claim that unilateral decisions by a party with almost no stake and almost no input from users of the affected scripts should be a basis for our decisions.
stevengj commentedon May 3, 2018
I'm not sure this is an accurate description of the Unifont developers.
Anyway, though we don't use it as the sole basis of our decisions, it seems like a more reasonable starting point than "all characters have width 1", which employs no input at all from users of the affected scripts.
Reasonable people can disagree about this, of course, but I don't think it's completely crazy for us to incorporate data from Unifont in determining charwidth for cases that are ambiguous in the Unicode standard.
stevengj commentedon May 3, 2018
By the way, regarding emoji being width 2, the lack of recognition of this prior to Unicode 9 led to this amusing issue in Julia that directly led to our attempt to get better charwidth tables: JuliaLang/julia#3721