Skip to main content
Be Bitwise

ASCII & Unicode

Data Representation · Data & Hashing track

3 min read

In this module

From Numbers to Letters

You already know computers store everything as binary numbers. So when you tap the letter A on your keyboard, how does the machine work out what you mean? Through a simple agreement — a lookup table mapping numbers to characters.

The ASCII Table

In 1963, engineers standardised a mapping called ASCII (American Standard Code for Information Interchange). Each character gets a number between 0 and 127 — fits snugly in 7 bits.

Here are a few landmarks in the table:

DecimalCharacterNotes
32(space)First printable
480Digit zero
65AUppercase letters
97aLowercase letters
10LFLine feed (newline)

Uppercase A is 65, B is 66, C is 67, and on. Lowercase letters start 32 positions later, so the difference between A and a in binary is one flipped bit.

The visualiser below holds 65, A. The bit worth 32 is bit 5, the third from the left. Turn it on and the value becomes 97, a. Turn it off again and you're back to A. Try it on other letters (Z is 90) and it works for every one of them, which is why old code converts case with a single OR, AND or XOR against 0x20.

27
26
25
24
23
22
21
20
Decimal65
Hex0x41
Binary01000001
Character Encoding

A character encoding is a mapping between numbers and characters. When a program reads the byte value 65, the encoding tells it to display the letter A. Without an agreed-upon encoding, the same bytes could mean completely different things on different systems.

Beyond English: Unicode and UTF-8

ASCII covers 128 characters — enough for English, digits, and basic punctuation, useless for Chinese, Arabic, emoji, or thousands of other symbols. Unicode sidesteps this by assigning a unique number (a code point) to over 150,000 characters drawn from every major writing system.

The most common way to store Unicode text is UTF-8, a sly variable-length encoding. ASCII characters still take one byte, so UTF-8 stays backward-compatible. Characters from other scripts use 2, 3, or 4 bytes as needed. An English document in UTF-8 is exactly the same size as plain ASCII, but the same file format also carries Japanese, Hindi, or a string of emoji without any mode switching.

Why This Matters

Every text file, every web page, every string in your program is ultimately a sequence of numbers read through a character encoding. Grasping the link between bytes and text is the foundation for working with files, network protocols, and data formats for the rest of your career.