News for hackers. Stuff that matters.
Re:TIL the assumption that string length does not change whe... by signal11 on Monday November 22, 2021 @06:12AM (#29305165)
Swift handles this really well,

"त्या".count // 1

"त्या".unicodeScalars.count // 4

"त्या".utf8.count // 12

Javascript's minimal library is of course not great, but there are libraries which can help, e.g. grapheme-splitter, although it's not language-aware by design, so in this instance it'll return 2.

graphemeSplitter.countGraphemes("त्या") // 2

There are no comments on this comment yet.