seegongsik
Structure

How does text become numbers

We said computers only understand numbers. Yet we type letters on a keyboard, and letters show up on the screen. In this lesson we look inside to see how a machine that only knows numbers handles text.

01

Every character has a number

The secret is simpler than you'd think.
People got together and gave every character a number.
A is 65, B is 66, and so on.
So when you press A on the keyboard, what reaches the computer isn't a letter but the number 65.

A→65
128
0
64
1
32
0
16
0
8
0
4
0
2
0
1
1
A = 65 = 0100 0001

Tap a character to see its number.

Uppercase A to Z, lowercase letters, digits, and symbols all have their own numbers.
This agreement that assigns numbers to characters is called ASCII.
It was the first code table computers widely used for text.

02

The number becomes 0s and 1s again

Remember the last lesson: computers store numbers as 0s and 1s too.
So the number 65 is also stored, in the end, as eight switches turned on or off.
One character becomes eight 0s and 1s.

A→65
128
0
64
1
32
0
16
0
8
0
4
0
2
0
1
1
A = 65 = 0100 0001

A is number 65, and that number turns into eight 0s and 1s.

So one English character usually takes up eight switches, which is 1 byte.
This is where the word for a group of eight, the byte, first appears.
Text, too, was 0s and 1s all along.

03

Opening up the code table

Below is what the ASCII table actually looks like.
The characters are lined up in number order, and each one has its number written next to it.
Uppercase A is 65, lowercase a is 97, and the digit 0 is 48.

!
33
"
34
#
35
$
36
%
37
&
38
'
39
(
40
)
41
*
42
+
43
,
44
-
45
.
46
/
47
0
48
1
49
2
50
3
51
4
52
5
53
6
54
7
55
8
56
9
57
:
58
;
59
<
60
=
61
>
62
?
63
@
64
A
65
B
66
C
67
D
68
E
69
F
70
G
71
H
72
I
73
J
74
K
75
L
76
M
77
N
78
O
79
P
80
Q
81
R
82
S
83
T
84
U
85
V
86
W
87
X
88
Y
89
Z
90
[
91
\
92
]
93
^
94
_
95
`
96
a
97
b
98
c
99
d
100
e
101
f
102
g
103
h
104
i
105
j
106
k
107
l
108
m
109
n
110
o
111
p
112
q
113
r
114
s
115
t
116
u
117
v
118
w
119
x
120
y
121
z
122
{
123
|
124
}
125
~
126

For the same letter, the lowercase number is 32 more than the uppercase one.

Here's a fun detail: uppercase and lowercase letters are exactly 32 apart.
A is 65 and a is 97.
That's no accident. The table was set up that way on purpose so computers could switch case easily.

04

Eight switches aren't enough

Eight switches can show 256 different patterns.
Even after fitting in the English alphabet, digits, and symbols, there's room to spare.
Since the agreement was made in the English-speaking world, that was enough at first.

0 ~ 255 · 256

From 0 to 255: 256 values in all.

But the world doesn't run on English alone.
Korean has more than ten thousand syllable characters, and Chinese characters number in the tens of thousands.
Add emoji, and 256 doesn't come close.
So a new agreement was needed.

05

Bigger characters use more bytes

The fix is simple.
If one slot isn't enough, use several.
In UTF-8, the most common encoding, English stays at 1 byte, Korean usually takes 3 bytes, and an emoji takes 4 bytes.
This huge table that gives a number to every character in the world is called Unicode.

A
One English letter
1 byte (1 slot)
0100
가
One Korean letter
3 bytes (3 slots)
1110
1011
1000
One emoji
4 bytes (4 slots)
1111
1001
1001
1000

Different characters take up different numbers of slots.

So even a single character can take up different amounts of space.
An English letter takes one slot, a Korean character takes three.
That's why the character count you see in a message can differ from what the computer counts.

06

A sentence is just a line of numbers

Now let's look at one short line all at once.
Each character turns into a number, and each number turns back into 0s and 1s.
Every message we send is, underneath, a long line of numbers like this.

Hi
H720100 1000
i1050110 1001

Hi, the way a computer sees it.

Showing text on a screen runs the same steps in reverse.
The computer reads the 0s and 1s, works out the number, finds the character for that number in the table, and draws it.
To our eyes it's text, but inside it's numbers from start to finish.

In one lineThe secret to how a number-only computer handles text is a table that gives every character a number. And those numbers, in the end, are the 0s and 1s from Lesson 1.
← Structure
Was this helpful? Support seegongsik