3 ms·
Yes, it’s definitely annoying that you can’t get the grapheme clusters of a string without going outside the standard library. That’s a very basic need when you
by avgcorrection 4y ago
Yes, it’s definitely annoying that you can’t get the grapheme clusters of a string without going outside the standard library. That’s a very basic need when you are dealing with user input and you care about the individual “characters” that have been sent in.
- easrng 4y agoYou can't get grapheme clusters but you can get actual codepoints by spreading a string into an array, ex [..."abc\uD83C\uDF08"] is ["a", "b", "c", "\u{1F308}"]
- kazinator 4y agoIf you carefully manipulate the array to produce some different array, and then convert back to string/text, you can preserve the grapheme clusters just fine. Just like the way string manipulating routines that don't know anything about Unicode can work with UTF-8 without breaking the text, simply by not truncating or separating the data in the middle of a UTF-8 sequence.