Combining characters explained

The letter “é” can be stored two completely different ways in Unicode — as one precomposed character, or as “e” plus a separate combining accent. This duality causes surprising bugs if you're not aware of it.

Precomposed vs decomposed

“é” can be U+00E9 (a single precomposed character) or U+0065 (e) + U+0301 (combining acute accent). Both look identical but are different byte sequences — so a naive equality check can say they're not equal.

Combining marks stack

Combining characters attach to the base character before them, and several can stack — this is how “Zalgo” text with towering accents is made. Each mark is its own code point layered onto the base.

The fix: normalization

Unicode normalization (NFC/NFD) converts text to a canonical form so equivalent strings compare equal. Normalize user input (usually to NFC) before comparing or storing it.

'e\u0301' === '\u00e9'                 // false
'e\u0301'.normalize('NFC') === '\u00e9' // true

Frequently asked questions

Why do two identical-looking strings not match?

One may use a precomposed character and the other a base letter plus a combining mark. Normalize (NFC) before comparing.

What are combining diacritical marks?

Code points that attach an accent or mark to the preceding character rather than being standalone letters.