CIE AS & A Level Computer Science, section 1.1 (Data representation)
Why a character set is needed
Computers can only store numbers. A character set is an agreed table that links each character to a unique binary code, so that data can be stored and shared.
ASCII
ASCII (American Standard Code for Information Interchange) uses 7 bits per character, giving characters: letters, digits, punctuation and control codes.
- The codes are in order: , , and so on, and , so a lower-case letter is 32 more than its capital.
- The digit characters start at .
Extended ASCII
Extended ASCII uses 8 bits, giving characters. The extra 128 codes hold accented letters and symbols. It is still not enough for most of the world's writing systems.
Unicode
Unicode uses more bits per character (commonly 8, 16 or 32 bits, as in UTF-8, UTF-16 and UTF-32) and can represent over a million characters, including all major languages, symbols and emoji. The first 128 Unicode characters are the same as ASCII.
| ASCII | Extended ASCII | Unicode | |
|---|---|---|---|
| Bits | 7 | 8 | 8 to 32 |
| Characters | 128 | 256 | over 1 000 000 |
| Languages | mainly English | some European | all |
| File size | small | small | can be larger |
Worked example
Store the word "Hi!" in ASCII: , , . In 7-bit binary these are , and .
Character codes in the exam
You are not expected to memorise particular character codes, but you should be able to work them out from a given one (for example, find the code for "F" given that "A" is 65).
Common mistake: saying Unicode "uses 16 bits". Unicode is a standard with several encodings of different lengths. Also, remember ASCII has 128 characters (7 bits), not 256.
Exam tip: when comparing character sets, mention the number of bits, the number of characters that can be represented, and the trade-off (more characters means larger files).
Check yourself
How many different characters can 8 bits represent?
.
If "A" has code 65, what is the code of "E"?
.
Why was Unicode introduced?
ASCII cannot represent the characters of most languages. Unicode uses more bits so it can represent all of them.