Unicode normalization problem

Rick Waldron waldron.rick at gmail.com
Wed Apr 1 19:05:55 UTC 2015


On Wed, Apr 1, 2015 at 2:59 PM monolithed <monolithed at gmail.com> wrote:

> ```js
> var text = 'ЙйЁё';
>
> text.split(''); // ["И", "̆", "и", "̆", "Е", "̈", "е", "̈"]
> ```
>
> Possible solutions:
>
> 1.
>
> ```js
> text.normalize().split('') // ["Й", "й", "Ё", "ё"]
> ```
>
> I like it, but is no so comfortable
>
> 2.
>
> ```js
> Array.from(text) // ["И", "̆", "и", "̆", "Е", "̈", "е", "̈"]
> ```
>
> 3.
>
> ```js
> [...text] // ["И", "̆", "и", "̆", "Е", "̈", "е", "̈"]
> ```
>
>
> Should the `Array.from` and `...text` work as the first example and why?
>

Why would they imply calling `normalize()`? What if that wasn't desired?

Since #1 calls normalize before split(), the actual equivalents would look
like this:

  Array.from(text.normalize()) // [ "Й", "й", "Ё", "ё" ]
  [...text.normalize()] // [ "Й", "й", "Ё", "ё" ]

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150401/80caf4c6/attachment.html>


More information about the es-discuss mailing list