AQA GCSE Computer Science (8525), section 3.3.5 (Character encoding)
Character sets
A character set is the list of characters a computer can use, with a unique binary code for each. Computers store text by storing the code for each character.
ASCII
ASCII (American Standard Code for Information Interchange) uses 7 bits for each character, so it can represent characters: upper and lower case letters, digits, punctuation and some control codes.
| Character | Code (decimal) |
|---|---|
0 |
48 |
A |
65 |
B |
66 |
a |
97 |
b |
98 |
Codes run in sequence
Codes for related characters are grouped and run in order:
- Capital letters: A = 65, B = 66, C = 67 ... Z = 90.
- Lower case letters: a = 97 ... z = 122.
- Digits: 0 = 48 ... 9 = 57.
So if you are given the code for A you can work out the others: H is 65 + 7 = 72, and a lower case letter is 32 more than its capital.
Converting using a table
You may be given an encoding table and asked to convert characters to codes and codes to characters.
Limits of ASCII
128 characters is not enough for other alphabets (such as Chinese, Arabic or Greek), or for symbols and emojis.
Unicode
Unicode uses more bits per character, so it can represent a far greater range of characters: almost all the world's alphabets, plus symbols and emojis.
- It is backwards compatible: the first 128 codes are the same as ASCII.
- It lets text from different languages be stored and shared.
- The disadvantage is that each character needs more bits, so text files are larger.
You do not need to know about UTF-8 or UTF-16.
Comparing
| ASCII | Unicode | |
|---|---|---|
| Bits per character | 7 | more (e.g. 16 or 32) |
| Characters | 128 | over a hundred thousand |
| File size | smaller | larger |
| Languages | basically English | worldwide |
Common mistake: mixing up the character 5 (code 53) and the number 5. Characters are stored as codes. Also, remember lower case codes are different from upper case ones, by 32.
Exam tip: use the given table to find a starting code, then count along the alphabet to find the others. For Unicode questions, say it has more bits, so it can store more characters such as other alphabets and emojis.
Check yourself
If A is 65, what is the code for E?
How many different characters can 7-bit ASCII represent?
Give one advantage of Unicode over ASCII.
It can represent a far greater range of characters, such as other alphabets and symbols.