Character Sets
When a computer stores text, it saves a string of characters as a sequence of ASCII codes — one code for each character, kept in the order you typed them. Each code is held as a binary pattern, because binary is the only thing the computer can store. So a short message becomes a short list of codes, and a long message becomes a long list.
A space is a character and has its own code, and so does every punctuation mark — commas, question marks, exclamation marks. Type Go, Sam! and you have stored eight characters, not five: G, o, comma, space, S, a, m and exclamation mark. Each one needs its own code and its own storage.
| Character | What it is | ASCII code (denary) |
|---|---|---|
| G | letter | 71 |
| o | letter | 111 |
| , | punctuation | 44 |
| (space) | space | 32 |
| S | letter | 83 |
| a | letter | 97 |
| m | letter | 109 |
| ! | punctuation | 33 |
In standard ASCII every character uses 7 bits, so the size of a string in bits is the number of characters multiplied by the number of bits per character. The eight characters of Go, Sam! take 8 × 7 = 56 bits. Leave out the space and the punctuation marks and you would get 5 × 7 = 35 bits, which is too small — the codes for those marks still have to be stored somewhere.
Edexcel GCSE Computer Science · Character Sets