Handle Unicode text, emoji, encoding, normalization, code points, and safe storage.
Lessons
Count what users see as one character.
Grapheme Clusters is easiest to learn by reading the example, changing it, and observing the result.
const text = 'Hi👋🏽 family👨👩👧👦!';
// Wrong: counts UTF-16 code units, splits emoji
console.log(text.length);
// Right: count what the user perceives as characters
const seg = new Intl.Segmenter('en', { granularity: 'grapheme' });
const graphemes = [...seg.segment(text)].map(s => s.segment);
console.log(graphemes.length, graphemes);Practice the Grapheme Clusters example in a small scratch file, then explain what changed and why.