ASCII Code Table

    We use the ASCII code table to encode characters in the computer. The ASCII standard uses 7 bit numbers from 0 to 127.

Do you learn better from video?

Learn faster with deeper understanding!
The "Computer programming for beginners" course is the perfect place to begin with programming.

Start now!

What is ASCII?

    The abbreviation ASCII stands for American Standard Code for Information Interchange. Originally it was designed to represent 128 characters(mainly from the alphabet). Today different additions exist. They use extended versions of the table with additional 128 characters. Each character is encoded with a 8 bit number (ranging from 0 to 255). Most of the characters are printable, but some are not – they are special characters and we will look at them more closely in a minute.
   
Note that the ASCII standard was never updated to include more than 128 characters. The additional characters are different standards and include different set of characters.

    The characters are ordered in a meaningful way. For instance all capital letters are grouped together, all digits are grouped etc.

The standard ASCII Code Table

Dec Hex Symbol Dec Hex Symbol Dec Hex Symbol Dec Hex Symbol
0 0x00 Null character 32 0x20 space 64 0x40 @ 96 0x60 `
1 0x01 Start of heading 33 0x21 ! 65 0x41 A 97 0x61 a
2 0x02 Start of text 34 0x22 " 66 0x42 B 98 0x62 b
3 0x03 End of text 35 0x23 # 67 0x43 C 99 0x63 c
4 0x04 End of transmission 36 0x24 $ 68 0x44 D 100 0x64 d
5 0x05 Enquiry 37 0x25 % 69 0x45 E 101 0x65 e
6 0x06 Acknowledgment 38 0x26 & 70 0x46 F 102 0x66 f
7 0x07 Bell 39 0x27 ' 71 0x47 G 103 0x67 g
8 0x08 Backspace 40 0x28 ( 72 0x48 H 104 0x68 h
9 0x09 Horizontal tab 41 0x29 ) 73 0x49 I 105 0x69 i
10 0x0A Line feed 42 0x2A * 74 0x4A J 106 0x6A j
11 0x0B Vertical tab 43 0x2B + 75 0x4B K 107 0x6B k
12 0x0C Form feed 44 0x2C , 76 0x4C L 108 0x6C l
13 0x0D Carriage return 45 0x2D - 77 0x4D M 109 0x6D m
14 0x0E Shift out 46 0x2E . 78 0x4E N 110 0x6E n
15 0x0F Shift in 47 0x2F / 79 0x4F O 111 0x6F o
16 0x10 Data link escape 48 0x30 0 80 0x50 P 112 0x70 p
17 0x11 Device Control 1 49 0x31 1 81 0x51 Q 113 0x71 q
18 0x12 Device Control 2 50 0x32 2 82 0x52 R 114 0x72 r
19 0x13 Device Control 3 51 0x33 3 83 0x53 S 115 0x73 s
20 0x14 Device Control 4 52 0x34 4 84 0x54 T 116 0x74 t
21 0x15 Negative Acknowledgment 53 0x35 5 85 0x55 U 117 0x75 u
22 0x16 Synchronous Idle 54 0x36 6 86 0x56 V 118 0x76 v
23 0x17 End of Transmission Block 55 0x37 7 87 0x57 W 119 0x77 w
24 0x18 Cancel 56 0x38 8 88 0x58 X 120 0x78 x
25 0x19 End of Medium 57 0x39 9 89 0x59 Y 121 0x79 y
26 0x1A Substitute 58 0x3A : 90 0x5A Z 122 0x7A z
27 0x1B Escape 59 0x3B ; 91 0x5B [ 123 0x7B {
28 0x1C File Separator 60 0x3C < 92 0x5C \ 124 0x7C |
29 0x1D Group Separator 61 0x3D = 93 0x5D ] 125 0x7D }
30 0x1E Record Separator 62 0x3E > 94 0x5E ^ 126 0x7E ~
31 0x1F Unit Separator 63 0x3F ? 95 0x5F _ 127 0x7F delete

ASCII Code Table – PDF

    For your convenience, I prepared a pdf version of the table. You can download and print it, if you need a paper copy of it.
To download, right click and choose “Save as” the following link: ASCII Code Table PDF.

Special ASCII characters

    The characters with code from 0 through 31, including 127 are not printable as a regular character. Some of them describe certain actions. Today, most of them are obsolete and chances are that you will not use them.

Let’s take a closer look to the special ASCII characters that are interesting for us for software development.

  • Code 0 – the null character. Escape sequence: '\0'
    We will use it various occasions. Its meaning is of empty space (not to be confused with the symbol space with code 32).
    One example: in C, we usually mark the end of an array with the null character.
  • Code 8 – backspace. Escape sequence: '\b'
    This one is not as often used as null. Still, it could be useful in some occasions.
  • Code 9 – horizontal tab. Escape sequence: '\t'
    The tab helps us when we want to format the output.
  • Code 10 – Line feed. Escape sequence: '\n'
    Line feed is probably the most frequently used of the special ASCII characters. In C we will use it almost every time when we output text.
  • Code 11 – Vertical tab. Escape sequence: '\v'
    Like horizontal tab, but tabs the content vertically, instead of horizontally.
  • Code 13 – Carriage return. Escape sequence: '\r'
    Returns to first position of the text line.

Input special characters in Windows

    If you are working on a PC with Windows, you may find this interesting.
Open a text editor and:

  1. Hold down the left Alt key
  2. Using the right number pad input the code of any ASCII symbol (you can input 08 for backspace)
  3. Release the Alt key

As a result the symbol with that code should appear.

    This also works for the numbers from 128 to 255. The default encoding for Windows above code 127 depends on the local and regional settings. For instance, if you are in Bulgaria or Russia, the codes around 128 to 159 will represent your alphabet in Cyrillic.

You can switch the encoding to ISO-8859 by entering one zero before the character.

Symbols you might want to try out:

  • Left Alt + 0128 = €   - euro sign
  • Left Alt + 0162 = ¢   - cent
  • Left Alt + 0163 = £   - pound
  • Left Alt + 0165 = ¥   - yen
  • Left Alt + 0169 = ©  - copyright sign
  • Left Alt + 0174 = ®  - registered trademark

Example in C: Print the ASCII Code table

    Here is a short routine that will print all characters and their codes from the ASCII code table. You will notice that the unprintable characters result in bizarre symbols  or formatting :-)

int main()
{
    unsigned char symbol = 0;
   
for(; symbol < 255; symbol++)
        printf("%d %x %c \n", symbol, symbol, symbol);
    return 0;
}


Read more about the characters in C programming language.

Do you learn better from video?

Learn faster with deeper understanding!
The "Computer programming for beginners" course is the perfect place to begin with programming.

Start now!

Did this help? Support me with your vote ;-)

Did this help?