Character encoding
CIE A-Level Computer ScienceΒ· Unit 1: Information representation, Topic 4Β· 15 min read
1. Principles of Character Encodingβ βββββ± 3 min
All text displayed on a computer is stored as binary data. A character set is a collection of characters that a system can encode, including letters, numbers, symbols, and control characters. Each character in the set is assigned a unique binary number.
Character encoding
The process of mapping each character in a character set to a unique binary value, so it can be stored or transmitted digitally.
Example:
The character 'A' is mapped to in ASCII.
A character set uses 7 bits per character. How many unique characters can this set encode?
- 1
Each bit can hold 2 possible values (0 or 1). For bits, the number of unique combinations is .
- 2
Substitute :
- 3
- 4
A 7-bit character set can encode 128 unique characters.
Exam tip:
Always remember that the number of unique characters is , not , for bits per character.
2. ASCII and Extended ASCIIβ β ββββ± 4 min
ASCII (American Standard Code for Information Interchange) is the most widely used early character encoding, originally designed for English language communication over early computer networks.
7-bit ASCII
A 7-bit encoding scheme that supports 128 characters, including upper/lowercase English letters, digits, punctuation, and control characters (e.g., line feed, backspace).
7 bits fit into an 8-bit byte, with one extra bit originally used for parity error checking. This bit was later repurposed to create extended ASCII.
Extended ASCII
An 8-bit encoding that extends 7-bit ASCII to unique characters, adding extra symbols and accented characters for Western European languages.
What is the minimum number of bytes required to store the string "HELLO CIE" using extended ASCII?
- 1
Extended ASCII uses 1 byte (8 bits) per character. Count all characters, including spaces.
- 2
Count characters: H, E, L, L, O, (space), C, I, E = 9 total characters.
- 3
- 4
The string requires 9 bytes of storage.
3. Unicodeβ β ββββ± 5 min
ASCII and extended ASCII only support a small number of characters, which is insufficient for non-English languages, emojis, and special academic or technical symbols. Unicode was developed to solve this problem.
Unicode
A universal character encoding standard designed to support all written languages, symbols, and emojis, with over 149,000 defined characters to date.
Unicode has multiple encoding formats (called Unicode Transformation Formats, or UTF) that vary in bit length per character:
UTF-8: Variable-length encoding, uses 1-4 bytes per character. Backwards compatible with 7-bit ASCII, and the most common encoding for the World Wide Web.
UTF-16: Uses 2 or 4 bytes per character, used for internal text storage in many operating systems.
UTF-32: Fixed 4 bytes per character, simple but inefficient for most everyday use.
Compare the storage of the string "Apple π" in UTF-8 versus extended ASCII. Explain why extended ASCII cannot display the emoji.
- 1
Count total characters: A, p, p, l, e, (space), π = 7 characters.
- 2
Extended ASCII only has 256 character codes, and no code exists for the emoji. It can only store the first 6 characters ("Apple ") and will display a replacement error character. Total size = 6 Γ 1 byte = 6 bytes.
- 3
In UTF-8, all ASCII characters (including the space) use 1 byte each, and the emoji uses 4 bytes.
- 4
- 5
UTF-8 correctly encodes all 7 characters in 10 bytes, while extended ASCII cannot encode the emoji.
4. Calculating Text Storage Requirementsβ β β βββ± 5 min
A common 3-5 mark exam question asks you to calculate the total memory size required to store a given block of text. The method follows a simple consistent process, regardless of the encoding.
A 100-page book uses 16-bit fixed-length Unicode encoding. If each page has 300 average words, each with 5 characters plus 1 space, calculate the total size in kilobytes (1 KB = 1000 bytes).
- 1
Calculate average characters per page: 5 characters + 1 space = 6 characters per word, 300 words per page = 300 Γ 6 = 1800 characters per page.
- 2
16-bit fixed encoding means 16 bits = 2 bytes per character.
- 3
Total characters for 100 pages: 100 Γ 1800 = 180,000 characters.
- 4
Check your understanding:
How many unique characters can be encoded with 10 bits per character?
1024
512
10
20
Reveal answer
1024 βCorrect: unique combinations.
5. Common Pitfalls
Wrong move:
Forgetting to count spaces and punctuation when calculating total storage
Why:
Most students only count visible letters, but all characters require encoding
Correct move:
Always count every character in the string, including whitespace and punctuation
Wrong move:
Calculating number of unique characters as instead of
Why:
Confusion between number of bits and number of possible binary combinations
Correct move:
Remember that bits give unique combinations, so always use exponentiation
Wrong move:
Assuming all Unicode is fixed length 2 bytes per character
Why:
Only 16-bit fixed Unicode uses 2 bytes; most common Unicode formats are variable length
Correct move:
Always use the bit length specified in the question, do not assume a default value
Wrong move:
Thinking extended ASCII is always compatible with Unicode
Why:
Only 7-bit ASCII is backwards compatible with UTF-8; extended ASCII uses non-standard extra codes that do not match Unicode
Correct move:
Remember that extended ASCII character values may map incorrectly to Unicode
6. Quick Reference Cheatsheet
Encoding | Bits per character | Max unique characters | Common use case |
|---|---|---|---|
7-bit ASCII | 7 bits | 128 | Basic English text |
Extended ASCII | 8 bits | 256 | Western European languages |
Fixed 16-bit Unicode | 16 bits | 65536 | Universal plain text |
UTF-8 | 1-4 bytes (variable) |
| Web pages, backwards compatible with 7-bit ASCII |
When this came up on past exams
AI-estimated based on syllabus patterns β cross-check with official past papers for accuracy. Use only as revision-focus signals.
- 2022 Β· 1
Memory size calculation question
- 2023 Β· 1
Compare ASCII and Unicode
Going deeper
What's Next
Character encoding is a core topic in information representation, and regularly appears as a short calculation question in Paper 1 of CIE 9618. Mastering the method for counting characters and calculating storage size is an easy way to secure marks in your exam. This concept underpins all work with text data, compression, and data transmission across networks. Next, you will move on to learning how other common types of media (images, audio) are represented as binary data in computer systems.
