demo Β· v143
Emoji segmenter
Unicode 16 added 8 new emoji groups including the face-with-bags-under-eyes, root vegetable, fingerprint, treble clef, and a new flag. The grapheme-cluster rules for these glyphs are non-trivial β they encode ZWJ joiners and skin-tone variants. Paste any text into the box and watch Intl.Segmenter split it into graphemes, words, and sentences correctly.
Live segmenter
Segments
Why ICU 77 matters here
- Each ICU upgrade ships updated grapheme-cluster rules. ICU 77 adds the segmentation tables for Unicode 16's new symbols.
- Pre-v143 browsers (on ICU 76 or older) split a U16 emoji into multiple "graphemes" β your
str.lengthover-counts, you render half a glyph, your truncation cuts in the middle. Intl.Segmenteris the spec'd way to count human-perceived characters across locales. v143 has the right tables.
const seg = new Intl.Segmenter("en", { granularity: "grapheme" });
const count = [...seg.segment("π¨βπ©βπ§βπ¦π¨πβπΏ")].length; // 3, not 19