Unicode and UTF-8/UTF-16: Code Points, Surrogate Pairs, Rune and Why string.Length Breaks on Emoji
string.Length breaks on emoji because .NET and JavaScript count strings in UTF-16 code units; the family emoji is one grapheme but 5 code points, 8 code units and 18 UTF-8 bytes. From ASCII to Unicode, code points, planes and scalar values, encoding UTF-8 and surrogate pairs by hand, Rune, u8 literals and the BOM, and counting a 280-character review limit correctly with StringInfo and Intl.Segmenter.
14 Nov 2026
·
11 min
·
6