Ascii

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Character Representation: ASCII

Introduction
Character data isn't just alphabetic characters, but also numeric characters, punctuation, spaces,
etc. Most keys on the central part of the keyboard (except shift, caps lock) are characters.
Characters need to be represented in binary. After all, computers store and manipulate 0's and 1's
(and even those 0's and 1's are just abstractions---the implementation is typically voltages).
The most common character representation is ASCII, which stands for American Standard Code
for Information Interchange.
There are two reasons to use ASCII. First, we need some way to represent characters as binary
numbers (or, equivalently, as bit string patterns). There's not much choice about this since
computers represent everything in binary.
The other reason we use ASCII is because of the letter "S" in ASCII, which stands for "standard".
Standards are good because they allow for common formats that everyone can agree on.

ASCII Code of characters. (in Hex)


00
01
02
03
04
05
06
07
08
09
0a
0b
0c
0d
0e
0f

nul
soh
stx
etx
eot
enq
ack
bel
bs
ht
nl
vt
np
cr
so
si

10
11
12
13
14
15
16
17
18
19
1a
1b
1c
1d
1e
1f

dle
dc1
dc2
dc3
dc4
nak
syn
etb
can
em
sub
esc
fs
gs
rs
us

Nice Properties

20
21
22
23
24
25
26
27
28
29
2a
2b
2c
2d
2e
2f

sp
!
"
#
$
%
&
'
(
)
*
+
,
.
/

30
31
32
33
34
35
36
37
38
39
3a
3b
3c
3d
3e
3f

0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?

40
41
42
43
44
45
46
47
48
49
4a
4b
4c
4d
4e
4f

@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O

50
51
52
53
54
55
56
57
58
59
5a
5b
5c
5d
5e
5f

P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_

60
61
62
63
64
65
66
67
68
69
6a
6b
6c
6d
6e
6f

`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o

70
71
72
73
74
75
76
77
78
79
7a
7b
7c
7d
7e
7f

p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
del

Even though character sets don't have mathematical properties, there are some nice aspects about
ASCII. In particular, the lowercase letters are contiguous ('a' through 'z' maps to 6116 through
7a16). The upper case letters are also contiguous ('A' through 'Z' maps to 4116 through 5a16).
Finally, the digits are contiguous ('0' through '9' maps to to 3016 through 3916).
Since they are contiguous, it's usually easy to determine whether a character is lowercase or
uppercase (by checking if the ASCII code lies in the range of lower or uppercase ASCII codes),
or to determine if it's a digit, or to convert a digit in ASCII to an int value.
The characters between 0 and 31 are generally not printable (control characters, etc). 2016 is the
space character, 0a16 is new line and 0d16 is carriage return.
Also, note that there are only 128 ASCII characters. This means only 7 bits are required to
represent an ASCII character. However, since the smallest size representation on most computers
is a byte, a byte is used to store an ASCII character. The MSb of an ASCII character is 0.
The difference in the ASCII code between an uppercase letter and its
corresponding lowercase letter is 2016. This makes it easy to convert lower to
uppercase (and back) in hex (or binary).

You might also like