UTF-8
The conceptHow one web page can mix English, accents, Chinese and emoji
Unicode gives every character a number, called a code point: 'A' is 65, 'é' is 233, '€' is 8364. UTF-8 is the rule for turning that number into bytes a file or network can store.
Small numbers get few bytes and big numbers get more, from 1 to 4 bytes. So plain English stays as compact as old ASCII, the 128-character code from the 1960s, while any other script still fits.
What it’s forDecides how many bytes UTF-8 uses for one character.
bytes(c) = 1 if c < 2⁷, 2 if c < 2¹¹, 3 if c < 2¹⁶, else 4
- c
- the character's Unicode code point, e.g. 233 for 'é'
- 2⁷
- 128: everything below this is plain ASCII
- 2¹¹
- 2,048: covers most accented Latin, Greek, Cyrillic, Arabic, Hebrew
- 2¹⁶
- 65,536: covers most Chinese, Japanese and Korean characters
What it givesA length from 1 to 4 bytes for each character.
- 'A' = 65 < 128 → 1 byte: 41
- 'é' = 233 < 2,048 → 2 bytes: C3 A9
- '€' = 8,364 < 65,536 → 3 bytes: E2 82 AC