OCR H446 · A Level Computer Science · ~10 min read
Notes
Video
Slides
Worksheet
Quiz
Why Character Encoding?
Computers can only store binary numbers. To represent text, we need a character encoding — a standard mapping that assigns a unique binary code to each character (letter, digit, symbol). Without a shared standard, a file written on one computer would be unreadable on another.
ASCII — American Standard Code for Information Interchange
ASCII was the first widely adopted character encoding standard:
7-bit ASCII: uses 7 bits per character → 2⁷ = 128 characters (code points 0–127)
Key pattern: 'A'=65, 'a'=97, difference = 32. To convert uppercase to lowercase: add 32. To convert lowercase to uppercase: subtract 32. Equivalently, toggling bit 5 (value 32) switches case.
Limitations of ASCII: only covers English characters. Cannot represent Chinese, Arabic, Greek, emoji, or most world scripts. This led to the development of Unicode.
Unicode
Unicode is a universal character encoding standard designed to represent every character in every language in the world:
Covers over 1,000,000 code points (currently around 140,000 characters assigned)
Code points are written as U+XXXX (e.g. U+0041 = 'A', U+1F600 = 😀)
Backwards compatible with ASCII — the first 128 Unicode code points match ASCII exactly
Supports emoji, mathematical symbols, historical scripts, and all major world languages
Unicode Encodings: UTF-8, UTF-16, UTF-32
Unicode defines code points (abstract numbers), but these must be encoded into bytes for storage. The main encodings are:
Encoding
Bits per character
Key features
UTF-8
Variable: 8–32 bits (1–4 bytes)
ASCII characters use 1 byte (same as ASCII). Most common on the web. Efficient for English text.
UTF-16
Variable: 16 or 32 bits (2–4 bytes)
Common in Windows and Java. BMP characters use 2 bytes; surrogate pairs for others.
UTF-32
Fixed: 32 bits (4 bytes)
Simple fixed-width encoding. Each character always uses 4 bytes. Wastes space for English text.
Why UTF-8 is Dominant
ASCII-compatible: existing ASCII text is valid UTF-8 without modification
Space-efficient for Western languages: most Latin characters are 1 byte
No byte-order issues (unlike UTF-16/32 which have endianness concerns)
Used by over 97% of web pages
Character Encoding and Storage
The file size of a text file depends on the encoding:
A 1000-character ASCII file = 1000 bytes (1 byte per character)
The same file in UTF-8 = 1000 bytes (ASCII chars = 1 byte each)
The same file in UTF-32 = 4000 bytes (4 bytes per character always)
Exam tip: Key ASCII values to memorise: 'A'=65, 'a'=97, '0'=48, Space=32. The difference between uppercase and lowercase is always 32 (bit 5 = 32). The character '0' is code 48, not code 0 — the digit 0 as a character is NOT the same as the null control character (code 0).
Exam tip: ASCII uses 7 bits (128 characters). Extended ASCII uses 8 bits (256 characters). Unicode uses variable-length encoding (UTF-8 is most common — 1 to 4 bytes per character). Unicode is backwards-compatible with ASCII — the first 128 code points are identical.
⚠ Common Mistakes
Confusing the character '0' (ASCII 48) with the null character (ASCII 0) — '0' is a printable character, ASCII 0 is a control code.
Saying Unicode uses "2 bytes per character" — this is only true for UTF-16 Basic Multilingual Plane characters. UTF-8 is variable (1–4 bytes), UTF-32 is always 4 bytes.
Forgetting that ASCII only uses 7 bits (not 8). Extended ASCII adds an extra bit for 256 characters, but standard ASCII is 7-bit.
✓ Notes completed!
▶
Video coming soon
Click to advance · Arrow keys also work
Click slide or press arrow keys to navigate
✍
Worksheet — 1.4.1d Character Encoding: ASCII and Unicode
8 questions · 20 marks · instantly marked
Q1How many different characters can standard 7-bit ASCII represent? Explain why.[2 marks]
✓ Mark scheme
7-bit ASCII can represent 2⁷ = 128 characters [1]. With 7 bits, there are 2⁷ = 128 possible unique bit patterns (0000000 to 1111111), one for each character [1].
Q2The ASCII code for 'A' is 65. What is the ASCII code for 'H'? Show your reasoning.[2 marks]
✓ Mark scheme
ASCII codes for letters are consecutive: A=65, B=66, C=67, D=68, E=69, F=70, G=71, H=72 [1]. 'H' is the 8th letter, so 65 + 7 = 72 [1].
Q3Explain why ASCII is insufficient for a modern global application, and why Unicode was developed.[3 marks]
✓ Mark scheme
ASCII only represents 128 characters [1], which is enough for English but cannot represent characters from other languages such as Chinese, Arabic, Japanese, Greek etc. [1]. Unicode was developed to provide a universal encoding that covers every character in every language in the world, allowing global software interoperability [1].
Q4Explain the difference between a Unicode code point and a Unicode encoding such as UTF-8.[3 marks]
✓ Mark scheme
A Unicode code point is an abstract number assigned to a character (e.g. U+0041 = 'A'), telling you which character it is — it is not yet a sequence of bytes [1]. A Unicode encoding (such as UTF-8) specifies how to convert code points into actual bytes for storage or transmission [1]. UTF-8 uses 1–4 bytes per character depending on the code point value — ASCII code points use 1 byte, higher code points use more [1].
Q5A text file contains the word "HELLO" (5 characters). Calculate its size in bytes when stored as (a) ASCII, (b) UTF-32.[2 marks]
✓ Mark scheme
(a) ASCII: 1 byte per character × 5 = 5 bytes [1]. (b) UTF-32: 4 bytes per character × 5 = 20 bytes [1].
Q6The ASCII code for lowercase 'a' is 97. Without looking it up, explain how you can find the ASCII code for uppercase 'A' and give the value.[2 marks]
✓ Mark scheme
The difference between the ASCII code for any lowercase letter and its uppercase equivalent is always 32 [1]. Therefore 'A' = 97 − 32 = 65 [1]. (Equivalently: bit 5 of the binary code distinguishes case — flipping bit 5 changes case.)
Q7Explain why UTF-8 has become the dominant encoding on the internet, while UTF-32 is rarely used for web content.[4 marks]
✓ Mark scheme
UTF-8 is dominant because: it is backwards-compatible with ASCII — any valid ASCII file is also valid UTF-8, so existing software and content does not need modification [1]; it is space-efficient for English/Latin text — common characters use only 1 byte, reducing file size and transmission time [1]; it has no byte-order (endianness) ambiguity [1]. UTF-32 is rarely used for web because every character uses 4 bytes regardless of whether it's a simple ASCII character — English text becomes 4× larger than necessary, wasting storage and bandwidth [1].
Q8Decode the following ASCII codes to find the hidden word: 67, 79, 77, 80, 85, 84, 69, 82. ('A'=65, 'a'=97, '0'=48)[2 marks]
Q1How many characters does standard 7-bit ASCII support?
Q2What is the ASCII code for the lowercase letter 'b'? ('a'=97)
Q3Which Unicode encoding uses a variable number of bytes (1 to 4) and is backwards-compatible with ASCII?
Q4The ASCII code for 'A' is 65 and for 'a' is 97. The difference (32) corresponds to:
Q5How many bytes does UTF-32 use per character?
Section B — Short Answer
Q6What is the ASCII code for the character '5' (the digit five)? ('0'=48)
Mark scheme'5' = 48 + 5 = 53. ASCII digit codes start at 48 for '0', then 49='1', 50='2', 51='3', 52='4', 53='5'. [1 mark]
Q7State one advantage of Unicode over ASCII.
Mark schemeUnicode can represent characters from any language/script in the world (over 1 million code points), whereas ASCII only covers 128 characters (mainly English). Unicode enables truly international/multilingual software. [1 mark]
Q8What does the notation U+1F600 represent in Unicode?
Mark schemeU+XXXX notation is a Unicode code point — U+1F600 is the code point assigned to the 😀 (grinning face) emoji. The U+ prefix indicates it is a Unicode code point, and 1F600 is the hexadecimal number of that character. [1 mark]
Q9Why are the first 128 Unicode code points identical to ASCII?
Mark schemeUnicode was designed to be backwards-compatible with ASCII — if the first 128 code points matched ASCII exactly, then existing ASCII text files and software would remain valid without any modification when Unicode was introduced. This made adoption much easier. [1 mark]
Q10A text file contains 100 characters of English text. Compare its size in UTF-8 versus UTF-32.
Mark schemeUTF-8: English characters (all in ASCII range) use 1 byte each → 100 bytes total. UTF-32: always 4 bytes per character → 400 bytes total. UTF-32 is 4× larger for English text because it uses fixed 4-byte storage even for simple ASCII characters that only need 1 byte. [1 mark]