String.prototype.normalize, case folding and sort keys

Nebojša Ćirić cira at
Wed Oct 23 15:09:52 PDT 2013

String.prototype.normalize(form) spec is here -
jorendorff/es6-draft.html#sec-string.prototype.normalize. It offers all 4
forms of normalization.

We did mention additional CF and CFNKFC forms for case folding, but they
were not added to the spec. They case fold string in a locale independant
way (see

Should we:
1. Add those two new forms to the spec of String.prototype.normalize(form)
2. Add a new String.prototype.toFoldCase(form) method?
3. Add Intl.Collator.prototype.sortKey(string)->string method?

We could do 1 and 3, or 2 and 3, or just 3.

Use case would be: user inputs M words, and we would like to see if some of
them match N predefined words (say to trigger an action). With current we need MxN comparisons. With
toFoldCase/sortKey we would need only O(M) queries to the hash with N keys.

Mihai and I lean towards 3. because it gives more control to the user on
what you want to check. For example, it doesn't make sense to ignoreCase
for locales that don't have case distinction. Or user may want to preserve
accents in the comparison...

Nebojša Ćirić
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list