Working with grapheme clusters

Mathias Bynens mathias at qiwi.be
Thu Oct 24 07:31:50 PDT 2013


On 24 Oct 2013, at 16:22, Anne van Kesteren <annevk at annevk.nl> wrote:

> On Thu, Oct 24, 2013 at 3:02 PM, Claude Pache <claude.pache at gmail.com> wrote:
>> As a side note, I ask whether the `String.prototype.symbolAt `/`String.prototype.at` as proposed in a recent thread,
>> and the `String.prototype[@@iterator]` as currently specified, are really what people need,
>> or if they would mistakenly use them with the intended meaning of `String.prototype.graphemeAt`
>> and `String.prototype.graphemes` as discussed in the present message?
>> 
>> Thoughts?
> 
> If we want to make it easier for developers to work with text, we should offer them functionality at the grapheme cluster level and not distract everyone with code units and code points. Thanks for making a proposal!

I’d welcome grapheme helper methods (even though the ES6 string methods already make it easier to deal with grapheme clusters than ever before), but I strongly disagree the string iterator should be changed. I think the use case of iterating over code points is much more common.

Imagine you’re writing a JavaScript library that escapes a given string as an HTML character reference, or as a CSS identifier, or anything else. In those cases, you don’t care about grapheme clusters, you care about code points, cause those are the units you end up escaping individually.



More information about the es-discuss mailing list