What character encoding is
Computers store text as numbers. A character encoding is the agreement about which number means which character. If text is saved with one encoding and read with another, you get garbled output — the famous ’ or � symbols, sometimes called mojibake.
ASCII: the original 128
ASCII maps 128 characters — English letters, digits, and basic punctuation — to the numbers 0–127. It's simple and universal, but it has no way to represent accented letters, emoji, or non-Latin scripts.
UTF-8: room for everything
UTF-8 is the modern standard. It can represent every character in every language, plus emoji, using 1 to 4 bytes per character. Crucially, it's backward-compatible: the first 128 characters are identical to ASCII, so plain English text is the same in both.
Avoiding garbled text
- Save files as UTF-8 (it's the default in most modern editors).
- Declare it in HTML with
<meta charset="utf-8">. - Set the right
Content-Typecharset on API responses. - When you see garbage, the fix is almost always matching the read encoding to the save encoding.
Frequently Asked Questions
Is UTF-8 better than ASCII?
For modern use, yes — UTF-8 supports every language and emoji while remaining compatible with ASCII for basic English text.
Why do I see ’ instead of an apostrophe?
That's UTF-8 text being read as a different encoding (often Latin-1). Re-reading it as UTF-8 fixes it.
Does UTF-8 use more space?
Only for non-ASCII characters. Plain English text is the same size as ASCII because those characters use a single byte.