3 ms·
There's Intl.Segmenter now which does Unicode Segmentation to count the amount of graphemes for example: https://developer.mozilla.org/en-US/docs/Web/JavaScript
by CryZe 2y ago
There's Intl.Segmenter now which does Unicode Segmentation to count the amount of graphemes for example: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter/Segmenter#grapheme https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
Though you are right in that I don't know of a built-in way to count Unicode Scalar Values (USVs).
- josephg 2y agoJavaScript’s recently added implementation of String[Symbol.iterator] iterates through Unicode characters. So for example, [...str] will split any string into a list of Unicode scalar values.