Study Guide

Representing Text

How a computer stores letters, digits and symbols as binary numbers using a character set, how ASCII works, and why Unicode was needed as well.

Lesson 1.6 Data Representation

For: Cambridge IGCSE Computer Science learners, or anyone who can already convert between binary and denary

Stage: Think

Notes in number code

Two fictional friends, Mei and Joe, pass notes in class using a secret code. Each letter is replaced by its place in the alphabet: A is 1, B is 2, C is 3, and so on.

Think it through

What numbers stand for the word CAT in Mei and Joe’s code? A computer can only store patterns of bits, so why might it need a code like this to store a message?

Show what happens

C is 3, A is 1 and T is 20, so CAT is 3, 1, 20. A computer cannot store a letter itself. It stores bits, and bits make numbers, so each character has to be given a number first. The number is then stored in binary.

Letters, digits, punctuation marks and spaces are all characters. For a computer to store text, every character is given a number, and that number is stored in binary. Mei and Joe’s list is a very small example of a character set: an agreed list of characters, each with its own code.

The list has to be agreed. If Joe used A = 0 instead of A = 1, every message from Mei would be read wrongly. Computers are the same: the sender and the receiver must use the same character set.

Stage: Discover

How many bits does a character need?

A fictional robot understands only eight symbols. Each symbol must have its own different pattern of bits.

Think it through

How many bits does each symbol need, if the robot knows eight symbols? What about 26 symbols, one for each capital letter?

Show what happens

Eight symbols need 3 bits, because 2³ = 8 patterns. Twenty-six symbols need 5 bits: 4 bits make only 2⁴ = 16 patterns, which is too few, and 5 bits make 2⁵ = 32, which is enough (with 6 patterns spare).

Check your understanding

A character set has 100 different characters. What is the fewest number of bits that gives every character its own pattern?
Show the answer

Answer: B. 7 bits, because 7 bits make 128 patterns.

2⁶ = 64 is too small and 2⁷ = 128 is enough, so 7 bits is the fewest. The more characters a set holds, the more bits each code needs.

Stage: Discover

ASCII: a code for English text

Computers need one common list, so a standard was agreed in the 1960s. Here are some of its codes, written in denary:

CharacterCodeCharacterCode
A65a97
B66b98
C67c99
D68d100
048250
149957

Think it through

Look at the patterns. What would the codes for E, for c and for the digit 3 be? And how far apart are A and a?

Show what happens

E is 69, c is 99 and the digit 3 is 51. The codes follow the order of the alphabet and of the digits, so one code is enough to work out its neighbours. A is 65 and a is 97, so a lower-case letter is 32 above its capital.

This list is part of ASCII, the American Standard Code for Information Interchange. ASCII uses 7 bits for each character, so it has 2⁷ = 128 characters, with codes 0 to 127. They include capital and lower-case English letters, the digits, punctuation, the space (code 32) and some control codes, such as the one for a new line.

Seven bits is an awkward size to store, so each ASCII code is normally kept in a byte of 8 bits, with a 0 added on the left. 65 is 100 0001 in 7 bits and 0100 0001 in a byte.

You are never expected to memorise ASCII codes. A question gives you the ones you need, as the table above does.

Characters to ASCII codes
CharacterDenary code8-bit binary code
A650100 0001
C
a
5
z

    Show the completed table
    CharacterDenary code8-bit binary code
    A650100 0001
    C670100 0011
    a970110 0001
    5530011 0101
    z1220111 1010

    Stage: Predict

    The digit 7 is not the number 7

    When you type 7 in a text message, the computer stores it as a character, with its own code in the character set. That is different from storing the number seven.

    Think it through

    In the first lesson, seven in binary was 0000 0111. Do you think a phone stores the character 7 in a text message as 0000 0111? Give a reason, and say which pattern you think it might use.

    Show what happens

    It does not. The character 7 has its own code in ASCII, which is the digit 0 (code 48) plus 7, giving 55, or 0011 0111. The number seven kept as a number is 0000 0111, but a character is stored by looking up its code.

    Storing the number seven gives 0000 0111, as in the first lesson. Storing the character 7 gives its ASCII code, 55, which is 0011 0111. The digit characters run in order from 0 = 48, so 7 = 48 + 7 = 55. A computer needs both: numbers it can calculate with, and digits as text it can display, such as the digits of a phone number.

    Check your understanding

    A word processor stores the character 4 as text. Which pattern does it store?
    Show the answer

    Answer: C. 0011 0100, because the code for 0 is 48 and 4 is 52.

    The character 4 has ASCII code 52, which is 0011 0100. The number four kept as a number would be 0000 0100.

    Now work the other way. A fictional text arrives as three bytes. You know that A is 65, B is 66 and so on.

    Decoding a message
    BinaryDenary codeCharacter
    0100 010068D
    0100 1111
    0100 0111

      Show the completed table
      BinaryDenary codeCharacter
      0100 010068D
      0100 111179O
      0100 011171G

      The three bytes spell DOG. The computer does not know it is reading a word: it follows the character set, one byte at a time.

      Stage: Think

      When 128 characters are not enough

      ASCII has 128 characters. That covers English text, but a fictional chat app called ChatBox is used by pupils who write in English, Arabic, Japanese and Polish, and who send emojis.

      Think it through

      Why can’t the 128 ASCII characters hold everything ChatBox needs? What could a designer do to give each character a code?

      Show what happens

      ASCII has no accented Polish letters, no Arabic or Japanese characters and no emojis. A designer can give every character a code by using more bits for each code, because every extra bit doubles the number of patterns.

      One fix is extended ASCII, which uses all 8 bits of a byte. That gives 2⁸ = 256 characters: the first 128 are the same as ASCII and the extra 128 hold accented letters and symbols. But 256 is still too few for the world’s writing, and different versions of extended ASCII use the extra codes for different characters.

      The lasting fix is Unicode: one character set designed to cover the writing systems of the world, as well as symbols and emojis. It has a far greater range of characters than ASCII, and so its codes need more bits per character. Some forms of Unicode use 16 or 32 bits for every character. 16 bits make 2¹⁶ = 65 536 patterns, and 32 bits make over four billion.

      The first 128 Unicode codes are the same as ASCII, so text in plain English has the same codes in both.

      Check your understanding

      Which statement best explains why Unicode was created?
      Show the answer

      Answer: A. ASCII has too few codes for many languages and emojis, so a set with more bits per character was needed.

      ASCII’s 128 characters (256 in extended ASCII) cannot cover the characters of many languages and emojis. Unicode has a much greater range, so each character needs more bits.

      Unicode was built to include ASCII. The first 128 Unicode codes are the ASCII codes, so A is still 65. Unicode adds characters; it does not change the old ones. That is why both are still taught and used: ASCII is a small, simple character set, and Unicode is the larger one that includes it.

      Stage: Apply

      What more bits cost

      More bits per character lets a character set hold more characters, but it also makes a stored message longer. A fictional school newsletter has 500 characters.

      Apply it

      Each ASCII character is stored in 8 bits (one byte). The newsletter is stored in a form of Unicode that uses 16 bits for each character. How many bytes does the newsletter need in each form?
      Show the answer

      Answer: C. 500 bytes in ASCII, and 1000 bytes in Unicode.

      ASCII: 500 × 8 bits = 4000 bits = 500 bytes. Unicode: 500 × 16 bits = 8000 bits = 1000 bytes. The same text takes twice the space.

      Apply it

      A fictional museum shop builds a website that shows its product names in English, Chinese and Spanish. Which character set should it use, and why?
      Show the answer

      Answer: B. Unicode, because it has a large enough range for Chinese characters and Spanish accents.

      The shop needs characters that ASCII does not have, so it needs Unicode. Unicode costs more bits per character, but without it the Chinese names could not be stored at all.

      Apply it

      Adaeze says: “Unicode is always better than ASCII, so ASCII should never be used.” Which reply gives the best reason to disagree?
      Show the answer

      Answer: C. For text with only English letters and digits, ASCII is enough and takes less space.

      Neither is better in every case. Unicode has the greater range, and ASCII needs fewer bits per character. The right choice depends on which characters have to be stored.

      Go deeper Beyond the specification: how one Unicode form saves space

      The forms of Unicode described above give every character the same number of bits. A popular form called UTF-8 uses a different plan: it stores the 128 ASCII characters in one byte each, and uses two, three or four bytes for the rest. English text then takes about the same space as ASCII, and other languages take more. This is why UTF-8 is common on websites. The specification only asks you to know that Unicode needs more bits per character than ASCII.

      Stage: Consolidate

      Bring it together

      Think it through

      Without looking back, explain to a friend how a computer stores the word “Hi” in a text message, and why a phone needs Unicode as well as the idea behind ASCII.

      Show a model answer

      Each character has a code in a character set: H is 72 and i is 105 in ASCII, and each number is stored in binary (0100 1000 and 0110 1001). A phone needs Unicode because ASCII’s 128 characters cannot hold other languages or emojis, and Unicode gives each character a longer code with more bits.

      Check your understanding

      Extended ASCII uses 8 bits for each character. How many different characters can it have?
      Show the answer

      Answer: A. 256, because 2⁸ = 256.

      2⁸ = 256. The codes 0 to 127 are the same as ASCII, and codes 128 to 255 are the extra characters.

      • A computer stores text by giving every character a number from a character set, and storing that number in binary. The sender and the receiver must use the same character set.
      • With n bits, a character set can have 2ⁿ characters, so more characters need more bits for each code.
      • ASCII uses 7 bits, so it has 128 characters (A is 65, a is 97, the digit 0 is 48), and is normally stored in a byte. Extended ASCII uses 8 bits and has 256.
      • The character 7 as text has its own code (55), which is not the number seven in binary.
      • Unicode has a far greater range, including other languages and emojis, and needs more bits per character. Its first 128 codes match ASCII.
      • ASCII is enough when only English letters and digits are stored, and uses less space. Unicode is needed when the range matters.

      Sources and scope

      • What this lesson is. The sixth lesson of the Data Representation module, written for this site. It teaches point 1 of Cambridge IGCSE Computer Science 1.2 (text and character sets) against the 2026 to 2028 syllabus (version 6). Its curriculum links are provisional: no link has been verified by the site owner. They show where the lesson may help with a course and imply no review or endorsement by any examination board.
      • Original material. Mei and Joe’s secret code, the robot with eight symbols, ChatBox, the school newsletter, the museum shop and Adaeze’s claim are fictional examples written for this lesson. The ASCII codes used are the standard ones (for example A = 65, a = 97, 0 = 48).
      • Simplified on purpose. Only the codes needed are shown, and no one is expected to memorise them. ASCII control codes and the many versions of extended ASCII are only named. Unicode is described by its range and its need for more bits per character; code points, and the different forms of Unicode, are left to the optional extension and to later study.