Professional Documents
Culture Documents
- Character Encoding
- Number Systems
- Other Encodings
Character Encodings
! !
Recall: the main representation used in our computers are bits (binary
representation), which can be either 0 or 1.
!
Question: So how does the computer know what we are trying to input?
!
! !
ASCII
Unicode
Gray Codes
Character Encodings
- base n number systems
! !
The base (radix) in a base n number system limits the number of possible
digits that a number can have. Here are some examples:
Name
Base
Possible Digits
Binary
Octal
Decimal
Hexadecimal
2
8
10
16
0, 1
0, 1, 2, 3, 4, 5, 6, 7
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Character Encodings
- base n number systems
! !
! !
Counting in base n:
Given m bits, we can represent
2m different characters
from 0 to 2m!1
(Ex.1-1)
decimal
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
binary
0
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
10000
octal
0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
20
hex.
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
10
Character Encodings
- base n number systems
! !
! !
!
!
Character Encodings
- base n number systems
! !
! !
Character Encodings
- other encodings
! !
! !
! !
In general,
Besides base n number systems, there are other ways to encode a character
(for input, output, memory, etc.)
!
BCD (Binary Coded Decimal)
!
Unicode
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
! !
! !
! !
ASCII table
B6 B5 B4
B3 B2 B1 B0
000
001
010
011
100
101
110
111
0000
null
dle
sp
0001
soh
dc1
0010
stx
dc2
0011
etx
dc3
0100
eot
dc4
0101
enq
nak
0110
ack
syn
&
0111
bel
etb
1000
bs
can
1001
ht
em
1010
lf
sub
1011
vt
esc
1100
ff
fs
<
1101
cr
gs
1110
so
rs
>
1111
si
us
del