GCSE Revision Aid: This resource is designed to support your revision and may contain errors. If you find a discrepancy with your class teaching, your teacher is correct — please let us know at gcserevise@scott.scottrix.co.uk.

CS19: Character Encoding

Foundation Higher AQAEdexcelOCREduqas

How computers represent text using ASCII and Unicode character encoding, key codes to remember, and converting between characters and codes.

Fastmail

📋 What is Character Encoding?

Character encoding is a system that assigns a unique numeric code to each character. Computers can only process numbers, so every letter, digit, and symbol must be represented by a number. The two main encoding systems are ASCII and Unicode.

Without character encoding, the binary pattern 01000001 could mean anything. Encoding standards ensure that 01000001 is always interpreted as the letter 'A'.

🔠 ASCII

ASCII (American Standard Code for Information Interchange) is a 7-bit character encoding system that represents 128 different characters. It was designed for English-language text and includes letters, digits, punctuation, and control characters.
ASCII Key Facts:
Uses 7 bits per character
Can represent 2^7 = 128 different characters
Characters 0-31: Control characters (non-printable)
Characters 32-126: Printable characters
Character 127: DEL (delete)

In practice, ASCII is stored in 1 byte (8 bits) with the leading bit set to 0.

Essential ASCII Codes to Remember

CharacterASCII Code (Decimal)Binary
'A'6501000001
'B'6601000010
'Z'9001011010
'a'9701100001
'b'9801100010
'z'12201111010
'0'4800110000
'1'4900110001
'9'5700111001
' ' (space)3200100000
Pattern to remember:
Uppercase letters: 'A' = 65 to 'Z' = 90 (26 letters)
Lowercase letters: 'a' = 97 to 'z' = 122 (26 letters)
Digits: '0' = 48 to '9' = 57 (10 digits)
The difference between 'a' and 'A' is always 32 (add 32 to convert upper to lower)
Finding Character Codes

What is the ASCII code for 'D'?

'A' = 65, 'B' = 66, 'C' = 67, 'D' = 68

What is the ASCII code for 'f'?

'a' = 97, 'b' = 98, 'c' = 99, 'd' = 100, 'e' = 101, 'f' = 102

Converting Characters to Codes in Pseudo-code
code ← ASC('A')       // code = 65
char ← CHR(65)        // char = 'A'

// Convert uppercase to lowercase
upper ← 'G'
lower ← CHR(ASC(upper) + 32)    // lower = 'g'

ASCII Character Groups

Code RangeCharactersCount
0-31Control codes (non-printable: newline, tab, bell)32
32-47Symbols and space16
48-57Digits 0-910
65-90Uppercase letters A-Z26
97-122Lowercase letters a-z26

🌍 Unicode

Unicode is a character encoding standard that supports characters from all languages in the world, plus symbols, emojis, and historical scripts. It can represent over 1 million different characters.
Unicode Key Facts:
Supports virtually every written language
Includes emojis, mathematical symbols, and technical symbols
Commonly stored using UTF-8 (variable length: 1-4 bytes)
Or UTF-16 (2 or 4 bytes per character)
The first 128 Unicode characters are the same as ASCII

Why Unicode Was Created

Unicode Examples Beyond ASCII
CharacterDescriptionUnicode Code Point
e-acuteLatin small letter e with acuteU+00E9
n-tildeLatin small letter n with tildeU+00F1
Chinese "middle"Chinese characterU+4E2D
Grinning faceEmojiU+1F600
Pound signCurrency symbolU+00A3
Euro signCurrency symbolU+20AC

⚖️ ASCII vs Unicode Comparison

Feature ASCII Unicode
Number of characters 128 Over 1 million
Bits per character 7 bits (stored in 1 byte) Variable (8-32 bits depending on encoding)
Languages supported English only All world languages
Emojis supported No Yes
File size Smaller (1 byte per character) Larger (2+ bytes for non-ASCII chars)
Compatibility Universal for English Backwards compatible with ASCII
When to use English-only text, small file size needed Multi-language text, modern applications

✅ Advantages of Unicode Over ASCII

Unicode is the modern standard because it solves ASCII's biggest limitation: only supporting English. With Unicode, any text in any language can be represented, stored, and transmitted correctly.
Unicode Backwards Compatibility

Unicode code points 0-127 are the same as ASCII:

  • Unicode U+0041 = 'A' (same as ASCII 65)
  • Unicode U+0061 = 'a' (same as ASCII 97)
  • Unicode U+0030 = '0' (same as ASCII 48)

This means any valid ASCII text is also valid Unicode text.

Trade-off: Unicode uses more storage space than ASCII. A plain English text file in Unicode (UTF-16) uses roughly twice the space of the same file in ASCII. However, with modern storage being cheap, this trade-off is usually acceptable.

🔄 Converting Characters to Codes and Back

ASC() and CHR() are the functions used to convert between characters and their numeric codes. ASC converts a character to its code; CHR converts a code to its character.
Character-Code Conversion Examples
// Character to code
OUTPUT ASC('A')       // 65
OUTPUT ASC('a')       // 97
OUTPUT ASC('0')       // 48
OUTPUT ASC(' ')       // 32

// Code to character
OUTPUT CHR(65)        // A
OUTPUT CHR(97)        // a
OUTPUT CHR(48)        // 0
Practical Application: Checking if Input is a Letter
INPUT "Enter a character: ", char
code ← ASC(char)
IF (code >= 65 AND code <= 90) OR (code >= 97 AND code <= 122) THEN
    OUTPUT char, " is a letter"
ELSE
    OUTPUT char, " is not a letter"
ENDIF
Converting a Digit Character to Its Numeric Value
// The character '7' has ASCII code 55, not value 7
digitChar ← '7'
digitValue ← ASC(digitChar) - ASC('0')    // 55 - 48 = 7
OUTPUT digitValue    // 7 (the number, not the character)

⚠️ Common Mistakes

Mistake Why It's Wrong How to Fix It
Thinking ASCII can store any character ASCII only has 128 characters - no foreign languages or emojis Use Unicode for non-English characters
Confusing '5' and 5 The character '5' has code 53, not value 5 Use ASC('5') - 48 to get the numeric value
Forgetting the +32 offset 'a' is not code 65 + 1, it is 65 + 32 = 97 Remember: lowercase = uppercase code + 32
Saying Unicode replaces ASCII Unicode includes ASCII (first 128 codes are the same) Unicode extends ASCII - it is backwards compatible
Not considering storage size Unicode can use more bytes per character Be aware of file size implications

❓ Practice Questions

Q1: What is the ASCII code for the letter 'M'?

Q2: How many characters can 7-bit ASCII represent?

Q3: Give two advantages of Unicode over ASCII.

Q4: Write pseudo-code that converts a lowercase letter to uppercase.

Q5: Explain why the character '3' and the integer 3 are stored differently in a computer.

✅ Answers

  1. 'A' = 65, so 'M' is the 13th letter: 65 + 12 = 77.
  2. 7-bit ASCII can represent 2^7 = 128 different characters.
  3. 1) Unicode supports all world languages while ASCII only supports English. 2) Unicode includes emojis and special symbols that ASCII cannot represent. Also acceptable: backwards compatible with ASCII, one universal standard eliminating regional encodings.
  4. INPUT letter
    code ← ASC(letter)
    IF code >= 97 AND code <= 122 THEN
        upper ← CHR(code - 32)
        OUTPUT upper
    ELSE
        OUTPUT "Already uppercase or not a letter"
    ENDIF
  5. The character '3' is stored as its ASCII code 51 (binary 00110011) and takes 1 byte. The integer 3 is stored as the binary number 00000011 (just the value 3). They look completely different in binary and are processed differently by the computer.

🎯 Exam Tips

⚠️ Common Errors

✗ Thinking ASCII and Unicode store the same number of characters ✓ ASCII uses 7 bits (128 characters) or 8 bits (Extended ASCII, 256 characters). Unicode uses up to 32 bits and can represent over 143,000 characters from all world languages.

✗ Believing Unicode always uses 4 bytes per character ✓ Unicode uses variable-length encoding: UTF-8 uses 1-4 bytes per character. Common ASCII characters still use just 1 byte in UTF-8, making it backward-compatible.

✗ Forgetting that ASCII cannot represent non-English characters ✓ ASCII only covers English letters, digits, and basic symbols. It cannot represent characters from other languages (Chinese, Arabic, etc.) — this is why Unicode was developed.

✗ Confusing character code with the character itself ✓ A character code (e.g. 65 in ASCII) is the numeric representation stored in memory. The character 'A' is how it is displayed. The computer stores 65, not 'A'.

✍️ Model Answer

Full-Mark Response

Explain why Unicode was developed as an alternative to ASCII, and discuss one advantage and one disadvantage of using Unicode. [4 marks]

Unicode was developed because ASCII could only represent 128 characters (or 256 in Extended ASCII), which is insufficient for the world's languages, symbols, and emoji. ASCII only covers English alphabet characters, digits, and basic punctuation. Advantage: Unicode supports over 143,000 characters from all writing systems worldwide, enabling global communication and multilingual documents in a single encoding standard. Disadvantage: Unicode requires more storage space per character than ASCII — up to 4 bytes compared to ASCII's 1 byte. This means text files are larger when using Unicode, though UTF-8 mitigates this by using 1 byte for ASCII characters.

📊 AO Deep Dive

Assessment Objective Analysis

AO1 (Computational Thinking — 40%): Demonstrate knowledge and understanding of the principles and concepts of computer science, including character encoding: ASCII and Unicode for AQA 8525, OCR J277 & Edexcel 1CP2.

AO2 (Application — 40%): Apply knowledge and understanding of computer science, including character encoding: ASCII and Unicode to analyse problems in computational terms and to design, write and evaluate solutions.

AO3 (Evaluation — 20%): Evaluate the effectiveness, correctness and efficiency of computational solutions, including character encoding: ASCII and Unicode, and make reasoned judgements about trade-offs.

📝 Exam Technique

GCSE Computer Science Exam Tips:
ASCII: 7-bit (128 chars) or 8-bit Extended (256 chars). Unicode: variable length, 143,000+ chars. Know why Unicode replaced ASCII (international support). ASCII advantage: small file size. Unicode advantage: universal character support. UTF-8 is backward-compatible with ASCII. When comparing, always discuss storage size vs character support trade-off.

📝 Exam Questions by Topic

🎬 Video Resources

Share this page

Ready to ace your GCSE Computer Science exams?

Get the best revision books and guides to boost your grades.