UTF-8 Bytes vs. Characters: Why Café Can Take 5 or 6 Bytes
Paste two versions of Café into a character counter. See what changes in UTF-8, what stays the same on screen, and which length to use for an input limit.

Suppose a tiny label printer allows five UTF-8 bytes for a shop name. You type Café and it fits. A colleague pastes what looks like the same name from a catalog, and the printer rejects it. Neither of you added a space. The difference is in the last letter: did the catalog store an accented é, or an e followed by an accent?
Paste the names one at a time
Open the Character Counter. Copy just the word from this first block, without a trailing line break:
Café
The counter shows Total: 4 and UTF-8: 5 B. The C, a, and f each take one byte. The last letter is a single Unicode code point, U+00E9, which needs two bytes in UTF-8.
Replace it with the word from this second block. Copy it rather than retyping it; your keyboard might produce the first version again.
Café
Now the result is Total: 5 and UTF-8: 6 B. In the frequency table, look for U+0065 (a plain e) and U+0301 (a combining acute accent). The accent has a row of its own even though it appears on the letter before it. If either total is one higher than expected, look for U+000A: that's a line feed from the paste.
Which count does the limit mean?
For the printer, the byte budget is the contract. For a text field promising “four characters,” the person typing is more likely to expect four visible units. An extended grapheme cluster approximates that unit: the e and its combining mark form one cluster. Both versions of the name contain four clusters. The counter's Total counts code points instead; it isn't a grapheme count.
JavaScript adds another useful but different measure. A string's .length counts UTF-16 code units. Try a single 🍋: it is one code point and one grapheme cluster, but its JavaScript length is two and it takes four UTF-8 bytes. That is why a check like name.length <= 5 is not a five-byte check.
const name = "Café";
const segments = new Intl.Segmenter("en", { granularity: "grapheme" });
[...segments.segment(name)].length; // 4
[...name].length; // 5
name.length; // 5
new TextEncoder().encode(name).length; // 6
Make an explicit choice about normalization
If your label format accepts normalized text, name.normalize("NFC") turns the decomposed ending in this example into U+00E9. Measure the normalized string, then send that same string to the printer. Measuring one version and transmitting the other would bring the bug right back.
Unicode normalization is not a way to squeeze arbitrary words into five bytes. It preserves canonical equivalence; not every combination has a single precomposed character. If the job is to reproduce the catalog file byte for byte, keep the original and inspect it in the Hex Viewer instead. For a length error, the most useful question to ask first is: a limit on what, measured at which step?