Unicode vs ASCII: What's the Difference and Why Does It Matter?

ASCII handles 128 characters. Unicode covers over 149,000. Understanding the difference explains why mojibake happens, how emoji work, and what UTF-8 actually does under the hood.

Have you ever pasted text from Word into a web form and seen "Ò€œ" where a curly quote should be? Or had an app crash because a user typed an emoji? That's a character encoding problem. Understanding ASCII, Unicode, and UTF-8 isn't just trivia β€” it explains why these bugs happen and how to fix them.

ASCII: 128 Characters and Nothing More

ASCII (American Standard Code for Information Interchange) was created in 1963 for telegraphs and early computers. It maps 128 characters to numbers 0–127:

  • 0–31: Control characters (newline, tab, null, bell)
  • 32–126: Printable characters (A–Z, a–z, 0–9, punctuation, space)
  • 127: Delete

That's it. No accented letters. No Cyrillic. No Arabic. No Chinese. No emoji. When the internet spread globally, ASCII was completely inadequate.

ASCII value of 'A' = 65 = 01000001 (1 byte)
ASCII value of 'a' = 97 = 01100001 (1 byte)
ASCII value of ' ' = 32 = 00100000 (1 byte)

"Hi" in ASCII: 72 105 β†’ two bytes

Extended ASCII: The Chaos Years

Computer makers in the 1980s needed characters beyond 128, so they used the 8th bit to define 128 more characters (values 128–255). But with no universal standard, every company defined their own mapping. Windows used CP1252. IBM used CP437. Macs used MacRoman. These incompatible "code pages" meant text from one system looked like garbage on another β€” the origin of mojibake (ζ–‡ε­—εŒ–γ‘).

Unicode: One Standard to Rule Them All

Unicode, first published in 1991, assigns a unique code point to every character in every writing system ever used β€” plus emoji, mathematical symbols, Braille, Egyptian hieroglyphs, and more. Current Unicode 15.1 covers 149,813 characters across 161 scripts.

Code points are written as U+XXXX (e.g., U+0041 = A, U+1F600 = πŸ˜€). The range U+0000 to U+007F is identical to ASCII β€” backward compatible by design.

Unicode β‰  UTF-8: The Encoding Question

Unicode is a standard (a table of code points). It doesn't say how to store them in bytes. That's what encodings do:

EncodingBytes per charASCII-compatibleUse case
UTF-81–4 (variable)βœ… YesWeb, APIs, files β€” the universal default
UTF-162–4 (variable)❌ No (0-byte issue)Windows internals, Java, C# strings, JavaScript
UTF-324 (fixed)❌ NoSimple processing, rare in practice
ASCII1 (fixed)βœ… Is ASCIILegacy systems only

How UTF-8 Works

UTF-8 uses a variable number of bytes depending on the code point's value:

U+0000 to U+007F: 1 byte β†’ 0xxxxxxx (plain ASCII, unchanged)
U+0080 to U+07FF: 2 bytes β†’ 110xxxxx 10xxxxxx
U+0800 to U+FFFF: 3 bytes β†’ 1110xxxx 10xxxxxx 10xxxxxx
U+10000 to U+10FFFF: 4 bytes β†’ 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx

'A' (U+0041) = 1 byte: 01000001
'Γ©' (U+00E9) = 2 bytes: 11000011 10101001
'δΈ­' (U+4E2D) = 3 bytes: 11100100 10111000 10101101
'πŸ˜€' (U+1F600) = 4 bytes: 11110000 10011111 10011000 10000000

Why Emoji Are 4 Bytes (And Why That Causes JavaScript Bugs)

JavaScript's String.length counts UTF-16 code units, not characters. For Basic Multilingual Plane characters (U+0000–U+FFFF), one character = one code unit. For emoji and other supplementary characters (U+10000+), one character = two code units (a "surrogate pair"). So:

"πŸ˜€".length === 2 // not 1!
"πŸ˜€"[0] === "οΏ½" // surrogate half
[...'πŸ˜€'].length === 1 // spread operator is Unicode-aware

This is why naively truncating strings at a character count can split a surrogate pair and produce corrupt output. Always use spread or Intl.Segmenter for Unicode-aware string manipulation.

The Mojibake Problem

The "Ò€œ" problem happens when UTF-8 text is interpreted as Windows-1252. The UTF-8 bytes for a curly left quote (U+201C) are C2 9C 80 β€” and those bytes, read as Windows-1252, produce Ò€œ. The fix is always to ensure your database, application, and browser agree on UTF-8 at every layer.

Exploring Character Encodings with ToollyX

The Text to Binary tool shows the exact binary representation of any text character by character. Try typing an emoji and watch the 4-byte UTF-8 representation appear. The URL Encoder shows percent-encoding of Unicode characters β€” each byte becomes %XX in URLs. And HTML Encoder converts characters to their HTML entity equivalents like ☃ for β˜ƒ.

πŸ”€
Explore text and binary conversions

See the exact bytes behind any Unicode character.

Open Text to Binary β†’