Text

String Inspector

Every way of counting a string at once — UTF-8 bytes, UTF-16 code units, code points and grapheme clusters — plus the code point behind each character and a flag on anything invisible, combining or deceptive.

Try
UTF-8 bytes
10
What goes over the wire
UTF-16 units
7
JS .length
Code points
6
[...str].length
Graphemes
6
What a reader counts

The four counts disagree, which is the usual source of truncated emoji and off-by-one column limits: a database VARCHAR(n) counts one of them, your validator probably counts another.

Findings
Astral plane characters

Code points above U+FFFF take two UTF-16 units, so slicing by JS string index can cut one in half.

Characters6 code points
c
0063
a
0061
f
0066
é
00E9
0020
👋
1F44B
Code point tableBytes and units each character actually occupies
#CharCode pointNameUTF-8UTF-16Escape
0cU+0063ASCII630063\u0063
1aU+0061ASCII610061\u0061
2fU+0066ASCII660066\u0066
3éU+00E9Latin-1 supplementC3 A900E9\u00E9
4U+0020Whitespace200020\u0020
5👋U+1F44BSupplementary planeF0 9F 91 8BD83D DC4B\u{1F44B}
NormalisationSame text under each Unicode normalisation form
FormCode pointsUTF-8 bytesChanges inputResult
NFC610nocafé 👋
NFD711yescafé 👋
NFKC610nocafé 👋
NFKD711yescafé 👋
UTF-8 hexContains multi-byte sequences
63 61 66 c3 a9 20 f0 9f 91 8b
Share

marduc812

© 202620260824_1c411cc