TechCompare LogoTechCompare

What is a character encoding? UTF-8, ASCII, and how computers store text

UTF-8 is the answer. Always. Unless you're maintaining a legacy system with a specific encoding requirement, every new file, API, and database column should be UTF-8. The encoding wars ended. UTF-8 won.

A character encoding is a mapping between human-readable characters and the bytes a computer stores. Without one, a byte value of 65 could mean A (ASCII), the first byte of a 2-byte Japanese character (Shift-JIS), or part of a 4-byte emoji (UTF-8). The encoding tells the computer which interpretation is correct.

By TechCompare · Updated

Encoding focus
Character encoding basics
character-encoding
Category
Fundamentals
Encoding concepts and theory

How this is calculated

Before Unicode, every language had its own encoding: Latin-1 for Western European languages, Shift-JIS for Japanese, GB2312 for Simplified Chinese. A file written in one encoding would render as gibberish (mojibake) when interpreted as another. Unicode solved this by assigning a unique number (code point) to every character across all writing systems. UTF-8 is the most popular Unicode encoding because it's backwards-compatible with ASCII, space-efficient for Latin text, and capable of representing the full Unicode range. UTF-16 is used internally by Windows and Java. UTF-32 is rarely used because it wastes space.

Verdict

Before Unicode, each language shipped its own encoding (Latin-1, Shift-JIS, GB2312), and a file written in one rendered as mojibake in another. Unicode fixed this by giving every character a unique code point, and UTF-8 became the dominant form because it stays byte-compatible with ASCII while scaling to the full character range. UTF-16 still powers Windows and Java internals. UTF-32 wastes space and is barely used.

More Encoding scenarios

Base64 vs Hex
Base64 and hexadecimal both encode binary data as text, but they serve different purposes.
View details ➜
UTF-8 vs ASCII
ASCII maps 128 English characters to 7-bit values.
View details ➜
URL encoding guide
Percent-encoding (also called URL encoding) replaces characters that aren't safe in a URL with a percent sign followed by two hex digits.
View details ➜

Frequently asked questions

What is a character encoding?
A mapping between human-readable characters and the bytes a computer stores. Without an agreed encoding, byte 65 could mean A in ASCII, the start of a two-byte character in Shift-JIS, or a quarter of an emoji in UTF-8. The encoding declares which interpretation is correct, which is why files and APIs carry encoding labels.
What was mojibake before UTF-8 became standard?
The garbled text that appeared when a file in one encoding was decoded as another. Latin-1, Shift-JIS, and GB2312 each covered one language family, and any cross-boundary document turned into symbol soup. Unicode fixed it by assigning every character in every writing system a single unique code point, and UTF-8 made that practical on the wire.
Where is UTF-16 used if UTF-8 dominates?
Inside Windows, Java, JavaScript, and .NET, where strings are stored as UTF-16 in memory. Those platforms standardized before UTF-8 won, when the two-byte fixed width looked simpler than a variable-length encoding. On disk, on the network, and in file formats, UTF-8 is the universal choice, and systems convert to UTF-16 only at the boundary.