News for hackers. Stuff that matters.
Re:You can't just assume UTF-8 by CryZe on Tuesday April 30, 2024 @04:50AM (#40208656)
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/Refe...

Though you are right in that I don't know of a built-in way to count Unicode Scalar Values (USVs).

Re:You can't just assume UTF-8 by josephg on Tuesday April 30, 2024 @09:18AM (#40210680)
JavaScript’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.