Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should len(string) return the number of graphemes, or the number of codepoints? #967

Open
christianp opened this issue Nov 21, 2022 · 1 comment

Comments

@christianp
Copy link
Member

In unicode, graphemes might be represented by a sequence of several codepoints. For example, the emoji 馃 is two codepoints: \ud83e\udef6.

Should the length of a string in JME count graphemes or codepoints? I think the least-surprising answer from a human's perspective is graphemes, but that means that all the methods for indexing and slicing strings need to be grapheme-aware.

@christianp
Copy link
Member Author

Blog posts on how this is dealt with in different languages:

Libraries to deal with grapheme clusters:

There is a proposal to add an Intl.Segmenter interface to JS to deal with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant