News for hackers. Stuff that matters.
Re:JavaScript’s internal character encoding: UCS-2 or UTF-16? by patorjk on Friday January 20, 2012 @08:17AM (#3489334)
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.
Re:JavaScript’s internal character encoding: UCS-2 or UTF-16? by finnw on Friday January 20, 2012 @12:29PM (#3490261)
Not quite. Surrogates (http://stackoverflow.com/q/5178202/12048) are UTF-16 code units but they are not UCS-2 code units.
Re:JavaScript’s internal character encoding: UCS-2 or UTF-16? by mathias on Friday January 20, 2012 @12:54PM (#3490381)
This.

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).