[Toybox] The cut -C test is failing because bionic's wcwidth() doesn't match glibc or musl.

Rob Landley rob at landley.net
Mon Oct 18 23:39:23 PDT 2021


Bionic's wcwidth() returns -1 (error) for combining characters, where glibc and
musl return 0 (does not increase the collective width of the displayed
characters). This means crunch_str() can't measure the length of the output, so
cut -C behaves like cut -c.

I admit the man page is written a bit confusingly, but combining characters are
technically printable, and therefore should have a length of at least zero.

Rob

P.S. This whole area is funky because the single dumbest thing about unicode is
that combining characters go _after_ the character they combine with, meaning
you can never tell when you've finished parsing a character until you've gone
PAST it and parsed a character that's does NOT attach to this one. Plus whenever
you get short input (typing, serial input, etc) your terminal keeps rewriting
the same character over and over every time it get a new combining character
that changes how the last character should render. If the combining characters
came BEFORE the non-combining character, the non-zero length character would
flush all the pending combining characters and you'd draw the resulting glyph
ONCE. But alas, Microsoft was on the unicode committee.



More information about the Toybox mailing list