UNICODE ENCODING
What is UTF-8?
UTF-8 is a variable-length Unicode encoding using 1–4 bytes per code point. It is especially common on the internet.
How does UTF-8 work?
ASCII characters such as Ause 1 byte. The Lithuanian letter ą usually uses 2, many other scripts use 3 and many emoji use 4 bytes.
| Character | Bytes |
|---|---|
A | 1 |
ą | 2 |
€ | 3 |
🙂 | 4 |
When is it used?
UTF-8 is a common choice for HTML, JSON, APIs, source code and data exchange. Its first 128 values match ASCII, so basic English text stays compact.
Practical tip
Explicitly specify <meta charset="UTF-8">in a web document, and actually save the file as UTF-8.
In brief
UTF-8 does not change the Unicode character's value. It only specifies how its code point becomes bytes for storage or transmission.