All data within a computer is stored in numeric format, even character data. Each character stored within a computer is stored as an 8-bit code (or on newer computers as a 16-bit code). The 8-bit code that we use is called ASCII (American Standard Code for Information Interchange). The newer, 16-bit code is called Unicode and allows a much larger set of possible characters that include the entire Greek, Hebrew, Arabic and Sanskrit alphabets.
All character manipulation is done using either ASCII or Unicode (Java, being a newer language, uses Unicode). Below, you will find a table showing the ASCII code (in base 10) for all the printable characters. Don't worry about the non-printing character; we aren't interested in them today.
Decimal | Printed Character | Decimal | Printed Character | Decimal | Printed Character | Decimal | Printed Character |
---|---|---|---|---|---|---|---|
32 | " " | 56 | 8 | 80 | P | 104 | h |
33 | ! | 57 | 9 | 81 | Q | 105 | i |
34 | " | 58 | : | 82 | R | 106 | j |
35 | # | 59 | ; | 83 | S | 107 | k |
36 | $ | 60 | < | 84 | T | 108 | l |
37 | % | 61 | = | 85 | U | 109 | m |
38 | & | 62 | > | 86 | V | 110 | n |
39 | ' | 63 | ? | 87 | W | 111 | o |
40 | ( | 64 | @ | 88 | X | 112 | p |
41 | ) | 65 | A | 89 | Y | 113 | q |
42 | * | 66 | B | 90 | Z | 114 | r |
43 | + | 67 | C | 91 | [ | 115 | s |
44 | , | 68 | D | 92 | \ | 116 | t |
45 | - | 69 | E | 93 | ] | 117 | u |
46 | . | 70 | F | 94 | ^ | 118 | v |
47 | / | 71 | G | 95 | _ | 119 | w |
48 | 0 | 72 | H | 96 | ` | 120 | x |
49 | 1 | 73 | I | 97 | a | 121 | y |
50 | 2 | 74 | J | 98 | b | 122 | z |
51 | 3 | 75 | K | 99 | c | 123 | { |
52 | 4 | 76 | L | 100 | d | 124 | | |
53 | 5 | 77 | M | 101 | e | 125 | } |
54 | 6 | 78 | N | 102 | f | 126 | ~ |
55 | 7 | 79 | O | 103 | g |
Use the table above to translate the sentence "Today is the first day of the rest of my life." into ASCII.
If we had translated "I saw red today." into ASCII, it would look like this:
I s a w r e d t o d a y . 73 32 115 97 119 32 114 101 100 32 116 111 100 97 121 46