The library character counter: one slot per code unit, one tile per grapheme. Why one emoji's .length can be 8, counted by the real Intl.Segmenter. An…
Why it matters
A bio length limit, a cut preview, a cursor position, a character counter: they all go wrong with .length once there is an emoji or a combined letter. The Segmenter gives a count that matches what a person sees, and knows the language.
Try it in this playground
Cut the preview in the middle of an emoji Move slice(0, n) until a red � tile shows: half a surrogate pair. The grapheme line under it stays whole.
Write café with a combined é (e + U+0301) .length becomes 5 but the graphemes 4. Two ways to write é, two different lengths.
Switch to granularity 'word' The Segmenter splits words by the rules of the language, not only at spaces. Useful for languages without spaces too, like Japanese and Thai.
Measure it yourself: a new Segmenter vs one reused In the Guestbook situation, press Measure: your own browser times how costly a new Segmenter is.