3 ms·
Code that treats UCS-2 as "wide ASCII" can be subtly wrong even for western european languages. For multiple reasons, Unicode has multiple representations for t
by estebank 6y ago
Code that treats UCS-2 as "wide ASCII" can be subtly wrong even for western european languages. For multiple reasons, Unicode has multiple representations for the same glyph[1], so if you have ü, it can either be a the two bytes 00FC[2], or u followed by the ¨ diacritic U+0308. If you don't account for this things like "reversing a string" or "give me a substring" or "how long is the string on screen" will be subtly buggy. If you handle UCS-2 correctly, then it's fine and a reasonable technical limitation, but the emphasis of that sentence is on correctly.
[1]: https://en.wikipedia.org/wiki/Unicode_equivalence https://en.wikipedia.org/wiki/Unicode_equivalence
[2]: https://www.compart.com/en/unicode/U+00FC https://www.compart.com/en/unicode/U+00FC
- Dylan16807 6y ago> Code that treats UCS-2 as "wide ASCII" can be subtly wrong even for western european languages. It can be. But critically for this conversation, fixing your code to support emoji and other non-BMP characters doesn't necessarily fix those problems.
- account42 6y agoExcept it does since a single emoji can also be made up of multiple code points.
- Dylan16807 6y agoBut that only causes subtle wrongness, which can continue to go unnoticed.