Unicode and UTF-8 for Software Engineers: What Actually Breaks

Text handling bugs show up in production as garbled names, truncated emoji and failed logins. A short mental model prevents most of them, and it is a frequent follow-up in coding interviews ("reverse this string", "count characters").

Three layers

  1. Code points: Unicode assigns every character a number, written like U+00E9 (é) or U+1F600 (an emoji). There are over a million possible code points.
  2. Encodings: UTF-8 stores each code point as 1 to 4 bytes and is backward compatible with ASCII. UTF-16 uses 2 or 4 bytes (surrogate pairs above U+FFFF) and is what JavaScript strings and Java char use internally.
  3. Grapheme clusters: what a user sees as one character may be several code points: a letter plus a combining accent, a flag (two regional indicators), or a family emoji joined with zero-width joiners.

Where code breaks

Rules of thumb

Use UTF-8 everywhere at the edges, decode bytes to text as early as possible and encode as late as possible, normalize identifiers, and never assume one character equals one byte.

Interview tip

If asked to reverse or truncate a string, ask whether the input may contain non-ASCII text. Mentioning code points versus graphemes is a strong signal of real-world experience.

Disclosure: I help build Linkjob AI, an AI copilot for job interviews - https://www.linkjob.ai/