Character Encoding Reference
A character encoding maps text to bytes. This table covers common encodings like ASCII, UTF-8, GBK, GB2312, Big5, ISO-8859-1 with meaning and typical use, helping with mojibake and encoding choices.
| Encoding | Meaning | Typical Use |
|---|---|---|
| ASCII | 7-bit charset covering English letters, digits and basic symbols (0-127) | Oldest base encoding, compatible subset of all modern encodings |
| UTF-8 | Variable-length Unicode encoding, 1-4 bytes | Web default; covers every language; Chinese is 3 bytes |
| UTF-16 | Unicode 2 or 4 byte encoding | Common in Windows/Java/.NET internals; JS string backing |
| UTF-32 | Fixed 4-byte Unicode encoding | Simple but bulky; rarely used for transfer |
| ISO-8859-1 | Latin-1, single-byte for Western European languages | HTTP default; often confused with Windows-1252 |
| Windows-1252 | CP1252, superset of Latin-1 with € and more printable chars | Windows Western default; browsers often parse 8859-1 as 1252 |
| GBK | Chinese internal code extension, double-byte for simplified+traditional | Old Chinese Windows default; compatible with GB2312 |
| GB2312 | Early simplified-Chinese double-byte encoding | Basic simplified charset, fully covered by GBK |
| GB18030 | Mandatory national standard covering CJK and minority scripts | Required by Chinese gov/finance; compatible with GBK |
| Big5 | Big-5, traditional-Chinese double-byte encoding | Traditional Chinese encoding in HK/Taiwan |
| Shift-JIS | Japanese encoding, mixed single/double byte | Japanese Windows default |
| EUC-KR | Korean double-byte encoding | Traditional Korean encoding |
Frequently Asked Questions
What is the difference between UTF-8 and GBK?
UTF-8 is a variable-length Unicode encoding covering every language — the de-facto web standard. GBK is a Chinese double-byte encoding covering only Chinese and English; it is smaller but cannot represent other languages. Modern projects should standardize on UTF-8 to avoid mojibake.
Why does mojibake (garbled text) happen?
Mojibake appears when text saved in encoding A is decoded as encoding B. The most common case is Chinese saved as GBK but read as UTF-8 (or vice versa). Keep file, database and HTTP charset (charset=utf-8) consistent to avoid it.
Are ISO-8859-1 and Windows-1252 the same?
No, but they are often confused. 8859-1 has control characters in 0x80-0x9F; 1252 puts printable characters there (e.g. €, smart quotes). Browsers often parse a declared 8859-1 as 1252, so 1252 is the clearer choice.
Which encoding do emoji use?
Emoji are Unicode; under UTF-8 they are usually 4 bytes (more for some new ones), and under UTF-16 a surrogate pair. As long as the system uses UTF-8, emoji store and display correctly.