Ask three programs how many characters are in βππ½β and you may get three answers: 1, 2 and 4. None is a bug. They are counting different things.
Three levels of βcharacterβ
Grapheme clusters are what a reader perceives as one character. βΓ©β, βππ½β, βπ³π±β and βπ¨βπ©βπ§β are each one grapheme. This is the right unit for anything a human reads or types.
Code points are the numbered entries in the Unicode standard, written like U+0041 for βAβ. Some graphemes need several code points:
- βΓ©β can be one code point (U+00E9) or two: βeβ plus a combining acute accent (U+0301). Both look identical.
- βππ½β is a thumbs-up (U+1F44D) plus a skin-tone modifier (U+1F3FD).
- βπ³π±β is two regional-indicator letters, N and L.
- βπ¨βπ©βπ§β is three people joined by two invisible zero-width joiners: five code points.
Code units are how code points are stored in memory. In UTF-16, used internally by JavaScript, Java and Windows, most common characters take one 16-bit unit, but anything beyond the first 65,536 code points, including most emoji, takes two. In UTF-8, used by most files and web pages, a code point takes one to four bytes.
The same text, counted four ways
| Text | Graphemes | Code points | UTF-16 units | UTF-8 bytes |
|---|---|---|---|---|
A | 1 | 1 | 1 | 1 |
Γ© (composed) | 1 | 1 | 1 | 2 |
Γ© (e + accent) | 1 | 2 | 2 | 3 |
ππ½ | 1 | 2 | 4 | 8 |
π¨βπ©βπ§ | 1 | 5 | 8 | 18 |
Why it matters
- Limits: many platforms, and many older systems, count UTF-16 units because that is what
string.lengthreturns in JavaScript. An emoji may use two of your allowed characters. - Databases: column limits in bytes mean non-English text fits fewer characters.
- Truncation: cutting text by code units can split an emoji in half, leaving a broken symbol.
- Comparison: the two forms of βΓ©β look identical but donβt match unless text is normalized to the same form (NFC is standard).
What TexaDocBase does
The Character Counter counts graphemes using the browserβs built-in Unicode segmentation, and also shows code points, UTF-16 units and UTF-8 bytes so you can match any system. Tools that compare text (duplicates, unique words, frequency) normalize to NFC first, and the Letter Counter treats both forms of βΓ©β as the same letter.