Unicode normalization problem

Mathias Bynens mathias at qiwi.be
Wed Apr 1 20:32:41 UTC 2015


On Wed, Apr 1, 2015 at 10:30 PM, monolithed <monolithed at gmail.com> wrote:
>> What you’re seeing there is not normalization, but rather the string
>> iterator that automatically accounts for surrogate pairs (treating them as a
>> single unit).
>
> ```js
> var foo = '𝐀';
> var bar = 'Й';
> foo.length; // 2
> Array.from(foo).length // 1
>
> bar.length; // 2
> Array.from(foo).length // 2
> ```
>
> I think this is strange.
> How to safely work with strings?

It depends on your use case. FWIW, I’ve outlined some examples here:
https://mathiasbynens.be/notes/javascript-unicode


More information about the es-discuss mailing list