2 ms·
> It's definitely not under the hood. Really? I'd love to see some references to that. I know there's some operations to convert a javascript string to UTF8,
by josephg 4y ago
> It's definitely not under the hood.
Really? I'd love to see some references to that.
I know there's some operations to convert a javascript string to UTF8, but everything which measures a string counts using 2-byte UCS2 items. For example, array-style indexing, string.length, str.charCodeAt(), split(), slice(), indexOf(), etc.
Also lots of DOM APIs use those weird string lengths too. For example, input element selectionStart / selectionEnd fields measure the selection range by counting surrogate pairs, not characters.
- Yoric 4y ago> Really? I'd love to see some references to that. I remember that SpiderMonkey shifted to multiple encodings around 2019 and v8 had done that earlier. Source: I was part of the SpiderMonkey team when the shift happened.