Unicode / counting guide

Count emoji and combining marks by the right unit

A visible character can have different counts as Unicode code points, JavaScript UTF-16 units and UTF-8 bytes. Name the unit in the input limit and measure with the same unit.

Separate the meaning of “one character”

FixtureDisplayedCode pointsUTF-16UTF-8
emoji 😀1124
combining é1223
family171125
ascii hello5555

Displayed graphemes describe what people see; code points are Unicode values, UTF-16 is JavaScript units, and UTF-8 is bytes.

Reproduce it with fixtures

Count emoji.txt, combining.txt, family.txt and ascii.txt in the same units, then compare expected.csv. The family emoji is one displayed sequence containing zero-width joiners.

const codePoints = [...text].length;
const utf16Units = text.length;
const utf8Bytes = new TextEncoder().encode(text).length;

Match the input limit

  1. Name displayed graphemes, code points, UTF-16 units or bytes in the specification.
  2. Count the fixture in that same unit.
  3. Include combining marks, emoji sequences and zero-width joiners.
  4. Give the recipient checklist.md with the fit decision and unit.

This guide is static browser-local material. Text and input are not sent to an external server.

Do not claim fit when the unit is unknown

If a specification says only “characters,” confirm the counting method before deciding that an input fits. Emoji and combining marks cannot be judged by appearance alone.