4 ms·
Very nice write up. I was actually looking for something like this about a week ago, and was referred to the ECMAScript spec (section 8.4) which talked about "U
by patorjk 15y ago
Very nice write up. I was actually looking for something like this about a week ago, and was referred to the ECMAScript spec (section 8.4) which talked about "UTF-16 code units" - which I believe is just UCS-2. If this is the case, I kind of wonder if the spec should be updated to make things a little more clear, since the issue isn't straight forward for those who don't know a lot about unicode.
- finnw 15y agoNot quite. Surrogates (http://stackoverflow.com/q/5178202/12048 http://stackoverflow.com/q/5178202/12048) are UTF-16 code units but they are not UCS-2 code units.
- mathias 15y agoThis. JavaScript’s internal encoding is closer to UCS-2 than it is to UTF-16, but it doesn’t guarantee that a string is valid UCS-2 (or valid UTF-16).