4 ms·
> (Though maybe this means you could convert latin1 to utf-16 by interleaving null bytes with the latin1 bytes?) Yes. In fact, things like JS JITs end up stori
by jcranmer 9y ago
> (Though maybe this means you could convert latin1 to utf-16 by interleaving null bytes with the latin1 bytes?)
Yes. In fact, things like JS JITs end up storing strings as either UTF-16 strings or Latin1 strings internally to take advantage of this fact.
- wereHamster 9y agoJavaScript uses (used, until a recent version) UCS-2, not UTF-16!
- ygra 9y agoMost JavaScript implementations have a bunch of different string types used internally, depending on what you're doing with the string. In-memory representation has no bearing on the API visible to the outside world. And while the JavaScript APIs only allow you to deal with UCS-2, the string contents themselves are, in fact, usually UTF-16.