The family emoji 👨👩👧👦 is one character to a reader, eleven UTF-16 units to JavaScript, seven code points, and twenty-five bytes in UTF-8. Every row here shows all four counts, which is how you find the length check that is quietly wrong.
What you can control
- Four length columns — UTF-16 units, code points, UTF-8 bytes and graphemes — that disagree on purpose.
- Nine case families, from combining marks to right-to-left overrides that reverse displayed text.
- The escaped-form column shows exactly which code points are involved.
- The RTL override case makes a filename display backwards, which is a real attack vector.
Testing ideas
- Length checks. Compare the UTF-16 length, code points, UTF-8 bytes and graphemes columns with what your validator counts. They disagree on emoji and combining marks.
- Bidirectional text. Use bidi cases to test that right-to-left overrides cannot disguise file names or links.
- Invisible characters. Zero-width characters test usernames that look identical but are not.
- Casing. Locale-sensitive cases such as Turkish dotless i test case-insensitive comparisons.
What this is not
Grapheme counting uses Intl.Segmenter where available. Older environments fall back to code-point counting, which will disagree with the browser's own rendering.