3 ms·
IIRC the real rationale is back in the early days people bet that 16 bits would be enough for a fixed length encoding, but the bet didn't pay off and now they'r
by jandrese 7y ago
IIRC the real rationale is back in the early days people bet that 16 bits would be enough for a fixed length encoding, but the bet didn't pay off and now they're stuck with the worst of both worlds.
- mehrdadn 7y agoDepends what you mean by "rationale" I guess. I was trying to explain why one might still want to use it, not why one might be stuck using it.
- lokedhs 7y agoYour explanation is correct. UTF-16 is a hack on top of a hack, and no one uses it in new software. However, Java and Javascript are stuck with it for legacy reasons. It wouldn't be so bad if people just understood that there are (almost) no valid uses-cases for measuring the size of a string. As someone else mentioned, it's a binary blob for all intents and purposes, and if processing of its content needs to be done (such as displaying it on the screen, or performing, say, word-wrap) then it should be handed over to libraries that have been designed for this purpose, because these things are very complicated. Simply by having a single non-ASCII character in my name, I'm seeing software fail on this on a regular basis.