CSC 306 Introduction to Programming with C++

ASCII Representation


ASCII Character Codes via Decimal

-0-1-2-3-4-5-6-7-8-9
0-NUL SOHSTX ETX EOT ENQ ACK BEL BS HT
1- LF VT FF CR SO SI DLE DCL DC2 DC3
2- DC4 NAK SYN ETB CAN EM SUB ESC FS GS
3- RS US space ! " # $ % & '
4- ( ) * + , - . / 0 1
5- 2 3 4 5 6 7 8 9 : ;
6- < = > ? @ A B C D E
7- F G H I J K L M N O
8- P Q R S T U V W X Y
9- Z [ \ ] ^ _ ` a b c
10- d e f g h i j k l m
11- n o p q r s t u v w
12- x y z { | } ~ DEL
To use the above table, you must convert the resulting decimal to binary.
Example: The character "H" is 72 in Decimal and 1001000 in binary ASCII


ASCII Character Codes via Hexadecimal (or BCD)

-0
---0000
-1
---0001
-2
---0010
-3
---0011
-4
---0100
-5
---0101
-6
---0110
-7
---0111
-8
---1000
-9
---1001
-A
---1010
-B
---1011
-C
---1100
-D
---1101
-E
---1110
-F
---1111
0-
000----
NUL SOH STX ETX EOT ENQ ACK BEL BS HT LF VT FF CR SO SI
1-
001----
DLE DCL DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC FS GS RS US
2-
010----
space ! " # $ % & ' ( ) * + , - . /
3-
011----
0 1 2 3 4 5 6 7 8 9 : ; < = > ?
4-
100----
@ A B C D E F G H I J K L M N O
5-
101----
P Q R S T U V W X Y Z [ \ ] ^ _
6-
110----
` a b c d e f g h i j k l m n o
7-
111----
p q r s t u v w x y z { | } ~ DEL
To use the above table, you must convert the hexadecimal or BCD to binary.
Example: The character "H" is 48 in Hexadecimal and 100 1000 in binary ASCII


Explanation of the unprintable ASCII Codes in the above tables

NUL (null)                   
SOH (start of heading)       
STX (start of text)          
ETX (end of text)            
EOT (end of transmission) - Not the same as ETB    
ENQ (enquiry)                
ACK (acknowledge)            
BEL (bell) - Caused teletype machines to ring a bell.  Causes a beep
             in many common terminals and terminal emulation programs.
BS  (backspace) - Moves the cursor (or print head) move backwards (left)
                  one space.
TAB (horizontal tab) - Moves the cursor (or print head) right to the next
                       tab stop.  The spacing of tab stops is dependent
                       on the output device, but is often either 8 or 10.
LF  (NL line feed, new line) - Moves the cursor (or print head) to a new
                               line.  On Unix systems, moves to a new line
                               AND all the way to the left.
VT  (vertical tab)           
FF  (form feed) - Advances paper to the top of the next page (if the
                  output device is a printer).
CR  (carriage return) - Moves the cursor all the way to the left, but does
                        not advance to the next line.
SO  (shift out) - Switches output device to alternate character set.            
SI  (shift in)  - Switches output device back to default character set.
DLE (data link escape)       
DC1 (device control 1)       
DC2 (device control 2)       
DC3 (device control 3)       
DC4 (device control 4)       
NAK (negative acknowledge)   
SYN (synchronous idle)       
ETB (end of transmission block) - Not the same as EOT  
CAN (cancel)                 
EM  (end of medium)  
SUB (substitute)             
ESC (escape) 
FS  (file separator)
GS  (group separator)
RS  (record separator)
US  (unit separator)         

Extended ASCII Codes

These were added later and are not true ASCII, nor is it standard.
There are different extended ASCII sets, but this set, known as OEM, is the most common.