AS Level · Topic 1.1
A-Level Computer Science 9618 / Topic 1 / AS

Every letter is a number.

When you press a key, the computer stores a number, not a letter. A character set is the agreed list that says which binary code stands for which character. Compare ASCII, extended ASCII and Unicode, and work out codes and storage from a code you are given.

The key idea

A character set is the complete list of characters a computer can represent, with a unique binary code for each one. ASCII uses 7 bits (128 characters: English letters, digits, punctuation and control codes). Extended ASCII uses 8 bits (256 characters), adding accented letters and symbols. Unicode uses up to 32 bits per character so it can represent every writing system and emoji; its first 128 codes match ASCII. Codes for letters are consecutive, so you can work out one code from another.

each character is stored as its code in the character set Hi 72105 0100 10000110 1001 charactercode (denary)stored in binary
Fig. 1: the text "Hi" stored as two character codes
Section 01

Characters as codes.

Type some text into the lab and watch each character become its code and then its binary pattern. Switch between the character sets and compare the bits needed.

Character setBits per characterCharactersCovers
ASCII7 (usually stored in a byte with a leading 0)27 = 128English letters, digits 0 to 9, punctuation, control codes
Extended ASCII828 = 256ASCII plus accented letters, currency and drawing symbols
Unicodeup to 32 (encodings such as UTF-8, UTF-16 and UTF-32)over a million possible codesall modern writing systems, symbols and emoji
Examiner trap

You will not be asked to memorise codes. The exam gives you one, such as 'A' = 65, and expects you to work out the others.

Section 02

Working out codes.

Because codes run in order (A, B, C ... and 0, 1, 2 ...), one known code unlocks the rest. In ASCII each lower-case letter is exactly 32 more than its capital.

Worked example Counting along
The ASCII code for 'A' is 65. Give the 8-bit binary code for 'G' and for 'g'.
  1. G is 6 letters after A: 65 + 6 = 71.
  2. 71 = 64 + 4 + 2 + 1, so 01000111.
  3. Lower case is 32 more: 71 + 32 = 103 = 64 + 32 + 4 + 2 + 1, so 01100111.
Answer: 'G' = 01000111, 'g' = 01100111
Worked example Digit characters
The code for the character '0' is 48. Give the code for the character '7', and explain how it differs from the integer 7.
  1. '7' is 7 places after '0': 48 + 7 = 55 = 00110111.
  2. The integer 7 is stored as 00000111.
  3. The character is only a symbol for display; it cannot be used in arithmetic until it is converted to a number.
Answer: '7' = 55 = 00110111, not 00000111
Your turn
Given 'A' = 65, which character has the code 01001011?
Examiner trap

A digit stored as a character is not the same as the number. The string "7" is code 55; the integer 7 is 00000111.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

How many characters can 7-bit ASCII represent?

Quick check+10 XP

In the lab, why does the Unicode version of the text need more bits than the ASCII version?

Quick check+10 XP

The code for 'a' is 97. What is the code for 'e'?

Quick check+10 XP

Which statement about extended ASCII is correct?

Section 03

How much space does text take?

Storage for plain text is the number of characters multiplied by the bits per character.

Worked example Extended ASCII or UTF-32
A message has 2400 characters. Calculate the storage needed in extended ASCII and in UTF-32, in KiB.
  1. Extended ASCII: 1 byte per character, so 2400 bytes.
  2. 2400 ÷ 1024 = 2.34 KiB (to 2 d.p.).
  3. UTF-32: 4 bytes per character, so 9600 bytes = 9600 ÷ 1024 = 9.375 KiB.
Answer: 2.34 KiB and 9.375 KiB
Your turn
A 500-character text uses UTF-16, with 2 bytes for every character. How many bits is that?
Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to AS Paper 1 and Paper 2 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

The ASCII code for 'M' is 77. What is the 8-bit code for 'P'?

Exam style+20 XP

Why was Unicode introduced?

Exam style+20 XP

A file holds 1000 characters in extended ASCII. How many bits does it need?

Exam style+20 XP

The code for 'A' is 65. A student stores the code 01100011. Which character is it?

Skill unlocked

Character sets, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
ASCII, extended ASCII and Unicode, working out character codes and the storage needed for text.