All subjects · Computer Science · WCP01 Principles of Computer Science
Character encoding: ASCII, extended ASCII, Unicode and UTF-8
Edexcel IAL Computer Science · WCP01 Principles of Computer Science
Text is stored by giving each character a number, called its code. A character set defines the codes (spec point 2.3.1).
ASCII and extended ASCII
- ASCII uses 7 bits per character, giving 27 = 128 codes: English upper and lower case letters, digits, punctuation, space and control codes (such as carriage return).
- Codes are in order, so arithmetic works: 'A' = 65, 'B' = 66, ... 'a' = 97 (lower case is upper case + 32), '0' = 48.
- Extended ASCII uses 8 bits, giving 256 codes; the extra 128 hold accented letters, symbols and line-drawing characters. Different versions (code pages) use the extra codes differently.
- Benefits: compact (one byte per character), simple, widely supported. Drawbacks: far too few codes for most of the world's languages; extended versions conflict, so text can display wrongly.
Unicode and UTF-8
- Unicode is a single character set that aims to give a unique number (code point) to every character in every writing system, plus symbols and emoji. It has room for 1 114 112 code points (U+0000 to U+10FFFF).
- The first 128 Unicode code points are the same as ASCII.
- UTF-8 is an encoding of Unicode that uses 1 to 4 bytes per character: ASCII characters use 1 byte, so ASCII text is also valid UTF-8; other characters use 2, 3 or 4 bytes.
- Benefits: represents virtually every language, one standard worldwide, backward compatible with ASCII, efficient for mainly English text. Drawbacks: non-ASCII characters take more storage than in an 8-bit code; variable length makes it harder to jump to the nth character.
| Character | Code point | UTF-8 bytes |
|---|---|---|
| A | U+0041 (65) | 1 |
| é | U+00E9 (233) | 2 |
| € | U+20AC (8364) | 3 |
| 😀 | U+1F600 (128512) | 4 |
Calculating text sizes
Storage = number of characters x bits per character. 500 characters in 7-bit ASCII need 3500 bits; in 8-bit extended ASCII, 500 bytes.
Worked example
The ASCII code for 'D' is 68. Find the code for 'h' and give it in 8-bit binary.
- 'h' is 4 letters after 'd'; 'd' = 68 + 32 = 100
- 'h' = 104
- 104 = 0110 1000
Answer: 104 = 0110 1000
Check yourself
- The ASCII code for 'A' is 65. What is the code for 'G'?
Show answer
71. G is 6 letters after A: 65 + 6 = 71.
- The ASCII code for 'M' is 77. What is the code for 'm'?
Show answer
109. Lower case = upper case + 32: 77 + 32 = 109.
- How many different characters can 7-bit ASCII represent?
Show answer
128. 27 = 128.
- A message of 250 characters is stored in 8-bit extended ASCII. How many bits does it need?
Show answer
2000 bits. 250 x 8 = 2000 bits.
- In UTF-8, how many bytes are used for the string 'Café' (C, a, f and é)?
Show answer
5. C, a and f are ASCII (1 byte each); é needs 2 bytes: 3 + 2 = 5.
- Why was Unicode developed?
- ASCII used too many bits per character
- Computers could not store numbers
- To make English text use more bytes
- ASCII and extended ASCII could not represent the characters of most of the world's languages
Show answer
ASCII and extended ASCII could not represent the characters of most of the world's languages. 128 or 256 codes are far too few for scripts such as Chinese, Arabic or Hindi.
- Which is a benefit of UTF-8?
- Every character uses exactly one byte
- Text written in ASCII is also valid UTF-8
- It can only represent English
- It uses fixed 4-byte codes, so it is easy to index
Show answer
Text written in ASCII is also valid UTF-8. UTF-8 keeps ASCII codes as single bytes, so old text still works.
- The ASCII code for '0' is 48. What is the ASCII code for the character '7'?
Show answer
55. 48 + 7 = 55. Note that the character '7' is not the number 7.
Sources
Last updated 8 November 2026. Spotted a mistake? Tell us.