Text feels like characters. Storage, wire protocols and length limits all operate on bytes, and the distance between the two is where emoji, accents and non-Latin scripts produce off-by-one surprises. A single visible glyph can occupy one, two, three or four bytes, and can also be several code points at once.
The same name, three different lengths
Take "café":
- 6 characters — the count most people expect
- 5 code points — nothing surprising here
- 6 bytes in UTF-8 —
étakes two
Take "👩👩👧👦", the family emoji:
- 1 visible glyph
- 7 code points — four emoji joined by three zero-width joiners
- 25 bytes in UTF-8
Why the distinctions matter in practice
Truncating a string at a byte limit can cut a multi-byte sequence in half, producing a decoder error on the receiving side. Counting code points when the API expects UTF-16 code units (as JavaScript does) shifts every index after the first astral character. Database column widths defined in characters behave differently from byte-length columns in the same table.
The workable habit is to always name the unit alongside the number. “Length 11” is incomplete; “11 UTF-8 bytes” or “11 UTF-16 code units” is a statement another engineer can reproduce. The Base64 Lab shows character, code point and byte counts side by side for exactly this reason, and it encodes the bytes you see rather than a reinterpreted version of them.
Nothing here requires a server: paste the sample, read the three counts, and the boundary that was invisible becomes a number you can put in a code review comment.
Where the three counts disagree most
The divergence concentrates in exactly the content that matters commercially: product names with diacritics, usernames with emoji, addresses in non-Latin scripts, and any identifier that crosses a legacy byte-width column. A signup form that validates “maximum 20 characters” while the database column holds 20 bytes will accept input it cannot store, and the failure surfaces as a 500 error rather than a message the user can act on.
The cheapest prevention happens at design time: pick one unit per field, write it into the field’s documentation, and validate in that same unit. Three counts on one screen make the pick easy to defend in review, and the same sample reused in tests keeps the choice honest across releases.