Re:TIL the assumption that string length does not change whe...
by arcticbull on Monday November 22, 2021 @01:27AM
(#29303446)
That’s both #2 and #3, because Unicode characters can have various widths including zero. Gotta find out how far to move the cursor.
[ Parent
| on HN ]
Re:TIL the assumption that string length does not change whe...
by ygra on Monday November 22, 2021 @06:34AM
(#29305289)
The Unicode character doesn't really have an intrinsic width; the font will define one (and I think a font could define a glyph even for things like zero-width spaces). But as soon as you want to display text you'll get into all sorts of fun problems and string length is most likely never applicable in any way. At that point the Unicode string becomes a sequence of glyphs from a font with their respective placements and there's no guaranteed relationship between the number of glyphs and the original number of code points, anyway.