SLIDE 1
CSZone.co.uk
Click to reveal · Arrow keys also work
OCR J277 · Component 1 · Topic 1.2.4e

Character Encoding

Character Sets · ASCII · Unicode · Bits and Capacity · Logical Ordering · Exam Practice

CSZone OCR GCSE Computer Science J277
Learning Objectives

By the end of this video you will be able to...

Explain what is meant by a character set, and that every character is given a unique binary code
Describe how ASCII represents characters, using 8 bits per character in the exam
Explain the relationship between the number of bits per character and the number of characters that can be represented
Describe Unicode and explain the differences and impact of different character sets
Understand that character sets are logically ordered — e.g. the code for 'B' is one more than the code for 'A'
⚡ You do NOT need to memorise any character codes — exam questions will give you one and expect you to work out others
Character Sets

What is a character set?

DEFINITION
A character set stores all of the characters that a computer can represent. Each character is given a unique binary code.
This includes letters (upper and lower case), digits, punctuation, symbols and control characters (e.g. "new line").
Lower-case and upper-case letters are given different binary codes — 'a' and 'A' are stored as two completely separate codes.
⚡ Without a shared character set, one computer's "01000001" could mean something completely different to another computer.
Binary Codes for Characters

Every character = a binary number

When you press a key, the computer doesn't store the letter itself — it stores the binary code that the character set assigns to it.
CharacterABa1!
Binary code0100000101000010011000010011000100100001
⚡ You don't need to memorise any of these codes — but you do need to understand how and why they work.
A piece of text is just a sequence of these binary codes, one after another, stored in memory.
ASCII

ASCII — 8 bits per character in the exam

ASCII
ASCII is a widely-used character set covering English letters (upper and lower case), digits, punctuation and common symbols.
In the OCR exam, ASCII characters are always represented using 8 bits — even if a code could fit in fewer bits, it is padded with leading 0s to make 8.
'A' stored using 8 bits
01000001
8 bits = 1 byte — so every ASCII character takes up exactly 1 byte of storage.
This means a 100-character text message takes up 100 bytes of storage when encoded in ASCII.
Bits & Capacity

More bits = more characters

THE RELATIONSHIP
The number of characters that can be represented is limited by the number of bits available. With n bits, you can represent 2ⁿ different codes.
BitsCalculationCharacters Possible
12
24
38
42⁴16
82⁸256
8 bits gives 256 possible codes — enough for the whole ASCII character set used in the exam.
If a character set needs more characters than 2ⁿ allows, it needs more bits per character.
Worked Example

How many bits do I need?

Exam-style question
A new character set needs to represent 50 different characters. What is the minimum number of bits required for each character?
BitsCalculationCharacters PossibleEnough for 50?
52⁵32✗ No
62⁶64✓ Yes
ANSWER
5 bits only gives 32 codes — not enough for 50 characters. 6 bits gives 64 codes, which is enough. Minimum = 6 bits.
⚡ Always round up to the next whole number of bits — you can never have a fraction of a bit.
Logical Ordering

Character sets are logically ordered

KEY IDEA
Within a character set, characters are arranged in a logical order — consecutive characters have consecutive binary codes.
The character code for 'B' will be one more than the character code for 'A'.
CharacterABCD
Code (denary)65666768
Each step along the alphabet adds +1 to the code.
If you know the code for one character, you can work out the code for any nearby character by counting how many places apart they are.
Worked Example

Using the ordering to find a code

Exam-style question
In ASCII, the character 'F' has the code 70. What is the code for the character 'L'?
FGHIJKL
70717273747576
Count the steps from 'F' to 'L': F→G→H→I→J→K→L = 6 places along the alphabet.
ANSWER
70 + 6 = 76. The code for 'L' is 76.
Unicode

Unicode — beyond English

THE PROBLEM WITH ASCII
ASCII's 256 codes are enough for English text, but not enough to represent characters from every language — e.g. Chinese, Arabic, Cyrillic — or symbols like emoji.
Unicode is a character set designed to represent characters from every writing system in the world, plus symbols and emoji.
To do this, Unicode characters use more bits per character than ASCII — applying the same rule: more bits = more possible codes = more characters.
⚡ The first 128 Unicode codes are deliberately the same as standard ASCII — so ASCII text is also valid Unicode text.
Differences & Impact

ASCII vs Unicode — what's the impact?

ASCII
Fewer bits per character → smaller file sizes, but a limited set of characters (mainly English).
UNICODE
More bits per character → far more characters can be represented (every language, symbols, emoji).
TRADE-OFF
More bits per character means each character takes up more storage — a Unicode file can be larger than the same text in ASCII.
WHY IT MATTERS
A system choosing a character set balances how many characters it needs against how much storage it can afford.
⚡ Exam phrasing: "Unicode can represent more characters than ASCII because it uses more bits per character, but this increases file size."
Exam Practice

Exam-Style Questions

Question 1 · 1 mark
State what is meant by the term "character set".
1 mark
ANS
A character set stores all of the characters that a computer can represent, with each character given a unique binary code.
Question 2 · 2 marks
A character set uses 4 bits per character. State the maximum number of characters this set can represent, showing your working.
2 marks
ANS
2⁴ = 16 characters
Question 3 · 2 marks
In a character set, the code for 'C' is 67. State the code for 'F', and explain how you worked it out.
2 marks
ANS
67 + 3 = 70. 'F' is 3 places after 'C' in the alphabet, so the code is 3 more than 67.
Common Mistakes

Four mistakes that cost marks

1
Trying to memorise ASCII codes. The spec does not require you to memorise any character codes — exam questions give you a starting code and expect you to work out others using the logical ordering.
2
Forgetting ASCII uses 8 bits in the exam. Always show ASCII codes as a full 8-bit binary number, padding with leading 0s where needed — e.g. 00100001, not 100001.
3
Confusing "more bits" effects. More bits per character means more characters can be represented — but it also means each character takes up more space. Both points may be needed for full marks.
4
Not rounding up when calculating bits needed. If 2ⁿ characters aren't enough, you need n+1 bits — never a fraction of a bit, and never round down.
Summary

1.2.4e — Character Encoding

CHARACTER SET
Stores all characters a computer can represent. Each character gets a unique binary code.
ASCII
8 bits per character in the exam = 1 byte. Covers English letters, digits, punctuation and symbols.
BITS & CAPACITY
n bits = 2ⁿ possible characters. More characters needed → more bits required.
UNICODE
Uses more bits than ASCII to represent every language and symbols/emoji — at the cost of larger file sizes.
⚡ Exam skill: character sets are logically ordered — work out unknown codes by counting places from a given code (e.g. 'B' = 'A' + 1).
CSZone.co.uk

That's 1.2.4e done.

Next up: 1.2.4f — Images in Binary

Full quiz, marked worksheet and slides at CSZone.co.uk