Secondary Computer Science / 1.2 Media Encoded as Data

1.2.1 Character Codes and Multilingual Text

🔒 Lesson slides are available to signed-in users. Sign in

1.2.1 Character Codes and Multilingual Text

A school information display may need to show English instructions, Chinese names, mathematical symbols and emoji. To a reader, these appear as meaningful characters. Inside the computer, however, every character must be represented using binary data.

A character set provides the agreed connection between a visible character and a numeric code. That code can then be stored and processed as a pattern of bits.

By the end of this section, you should be able to:

  • explain why text must be converted into numeric codes;
  • describe the role of a character set;
  • explain how a character code becomes binary data;
  • compare the range and purpose of ASCII and Unicode;
  • explain why uppercase and lowercase letters need different codes;
  • apply character coding to short messages and unfamiliar situations.

From visible characters to binary data

A computer cannot store the shape of a letter merely by recognising it as a person would. Instead, an agreed number is assigned to each character. The computer stores the number using binary.

Character 字符: one item of text, such as a letter, digit, punctuation mark, symbol or emoji.

Character code 字符编码值: a numeric value assigned to a character.

Character set 字符集: an agreed collection of characters and the codes assigned to them.

Encoding 编码: the process or rules used to represent information with coded values.
1 Character

A person enters a letter, digit, symbol or other text character.

2 Numeric code

The character set provides the number assigned to that character.

3 Binary representation

The numeric code is represented using bits so that it can be stored.

4 Displayed text

When the data is read, the code is mapped back to the correct character.

This process works only when the software reading the data uses compatible encoding rules. The bit pattern itself does not visually resemble the character it represents.

Common mistake

A character is not stored as a tiny picture of the letter. In ordinary text data, the character is represented by an assigned numeric code.

How a character set gives meaning to codes

Imagine a small electronic noticeboard designed to display only six symbols. Its designer could create the following local character set:

Character Assigned denary code Three-bit representation
A 0 000
B 1 001
C 2 010
? 3 011
! 4 100
Space 5 101

In this invented system, the pattern 001 represents B because the table says that code 1 is assigned to B. Another system could assign code 1 to a different character.

Answer-building tip

Explain the complete relationship:

A character set assigns a numeric code to each supported character, and that number is represented in binary for storage and processing.

ASCII: a compact set for basic text

ASCII was developed to provide standard codes for a core collection of characters. It includes English letters, denary digits, punctuation marks and control characters.

ASCII 美国信息交换标准代码: a standard character set designed around a relatively small collection of English-language characters, digits, punctuation and control codes.

Basic ASCII defines 128 code values. In this course, ASCII examples are shown as eight-bit groups so that each code occupies one byte-sized pattern. The unused position appears as a leading zero.

Character ASCII denary code Eight-bit classroom representation
Space 32 00100000
! 33 00100001
0 48 00110000
A 65 01000001
Z 90 01011010
a 97 01100001
z 122 01111010

Students do not normally need to memorise an entire ASCII table. The important idea is that each supported character has an agreed code.

Common mistake

ASCII is not a method for storing only letters. It also includes digits, punctuation, spaces and special control codes.

Uppercase, lowercase and punctuation are different characters

A character set must distinguish characters that look related but have different meanings or uses. Uppercase A and lowercase a therefore have different codes.

Character ASCII denary code Why a separate code is needed
A 65 Represents the uppercase form
a 97 Represents the lowercase form
1 49 Represents the text character “1”
! 33 Represents an exclamation mark
Space 32 Separates words even though no visible mark appears
Case-sensitive 区分大小写: treating uppercase and lowercase versions of a letter as different characters.

Common mistake

The text character “1” is not stored as the numeric value 1. It has its own character code because it is part of a text string.

Worked example: encoding a short message

A sports hall display needs to store the message:

Go!

Step 1: separate the characters

The message contains three characters: uppercase G, lowercase o and an exclamation mark.

Step 2: look up each ASCII code

Character ASCII denary code Eight-bit representation
G 71 01000111
o 111 01101111
! 33 00100001

Step 3: store the codes in order

01000111  01101111  00100001

The order is essential. Rearranging the codes would rearrange the displayed characters.

Answer-building tip

When describing text encoding, refer to characters individually. A message is stored as an ordered sequence of character codes rather than as one code for the entire word.

Decoding stored character data

Decoding reverses the process. Each binary group is interpreted as a number, and the character set is used to find the matching character.

Consider the following three ASCII groups:

01001111  01001011  00111111

Binary group Denary code Character
01001111 79 O
01001011 75 K
00111111 63 ?

The decoded message is OK?

Common mistake

Keep the boundaries between character codes. Combining or splitting the binary groups incorrectly may produce different numbers and therefore different characters.

Unicode: supporting writing systems from around the world

ASCII is useful for a limited collection of basic characters, but modern systems must represent far more. Users may need Chinese characters, Arabic writing, accented letters, mathematical notation, currency symbols and emoji.

Unicode 统一码: an international character standard that assigns codes to a very large range of characters and symbols.

Code point 码点: the number assigned to a character in Unicode, commonly written using a form such as U+0041.
Character Unicode code point Example category
A U+0041 Latin uppercase letter
é U+00E9 Accented Latin letter
م U+0645 Arabic letter
U+5B66 Chinese character
U+20AC Currency symbol
🌍 U+1F30D Emoji

Unicode code points are converted into stored bytes by an encoding such as UTF-8. At this level, the central idea is that Unicode provides a much wider character range than basic ASCII and may require more data to represent characters.

Common mistake

Unicode is not used only for emoji. It supports writing systems, technical symbols, punctuation and many other character categories.

Comparing ASCII and Unicode

Comparison point ASCII Unicode
Character range A relatively small collection A very large international collection
Typical coverage Basic English letters, digits, punctuation and control codes Many languages, symbols, specialist notation and emoji
Data requirements Basic characters can be represented compactly Some characters require more bits or bytes
Main advantage Simple and compact for its supported character range Supports communication across many languages and systems
Compatibility Its original codes are retained within Unicode Can represent ASCII characters as well as many additional ones

Compare both sides

A strong comparison addresses the same feature:

ASCII supports a smaller set of mainly basic English text characters, whereas Unicode supports characters from many writing systems and a much larger collection of symbols.

Why multilingual character support matters

A digital system may be used by people in different regions or by speakers of different languages. Limiting the available character set could prevent users from entering names, addresses, messages or subject-specific notation correctly.

System Character requirements Possible problem with a limited set
International school database Names written in several scripts Students' names may be altered or rejected
Travel information display Local and international languages Some passengers may be unable to read the instructions
Scientific document Greek letters and mathematical symbols Equations may lose their intended meaning
Messaging application Languages, symbols and emoji Users may be unable to express the intended message

Explain the practical consequence

Do not only state that Unicode contains more characters. Explain why that matters, such as allowing users to store names and messages accurately in different languages.

The sender and receiver need compatible rules

When character data is stored or transmitted, the receiving software must interpret the bytes using the intended encoding. Otherwise, the wrong symbols may be shown.

1. Original text

A user enters a message.

2. Encoding

Characters are converted into stored byte patterns.

3. Transmission or storage

The bytes are saved or sent to another device.

4. Decoding

The intended rules are used to reconstruct the characters.

Common mistake

A file containing text does not automatically explain how every byte should be interpreted. The software must know or determine the correct encoding.

Interactive: Character Code Laboratory

Enter English, multilingual text, punctuation or emoji. The laboratory shows how individual characters are assigned numeric codes and represented in binary.

Interactive investigation

Turn characters into numeric codes

Characters analysed 6 Unicode code-point view
1. Select a character-set view

Unicode assigns code points to characters from many languages, symbols and emoji.

Unicode mode can inspect letters, symbols and emoji.
Current coded sequence U+0047 · U+006F · U+0021 · U+0020 · U+5B66 · U+1F30D

2. Inspect each character

Selected character G

G has Unicode code point U+0047, denary value 71 and binary value 1000111.

ASCII decoding challenge

Decode the eight-bit groups

01000011 01001111 01000100 01000101

Each group represents one basic ASCII character.

Decode the message and check your answer.

Focus on the mapping

The essential process is: character → assigned number → binary representation. Do not treat the visible shape of a character as the stored data.

Practice

Core questions

  1. Define the term character set.
  2. Explain how a character such as K can be stored as binary.
  3. State three categories of character included in ASCII besides uppercase letters.
  4. Explain why uppercase A and lowercase a require different character codes.
  5. The ASCII code for H is 72 and the ASCII code for i is 105. Write the denary code sequence for Hi.
  6. Convert the ASCII denary codes 67, 83 and 33 into characters.
  7. Explain one limitation of using only basic ASCII in an international messaging system.
  8. Explain why Unicode is suitable for storing student names from many countries.
  9. Describe one similarity and one difference between ASCII and Unicode.
  10. Explain why a space needs its own character code even though it is not visibly printed.
  11. A text file is decoded using different rules from those used when it was encoded. Describe a possible consequence.
  12. Explain why the text character “7” and the numerical value 7 should not automatically be treated as the same stored value.

Extension questions

  1. A custom character set contains 70 different characters. Determine the minimum number of bits required for one fixed-width character code.
  2. A system uses six bits for every character. Calculate the maximum number of different character codes available.
  3. Explain why adding more available bit patterns allows a character set to represent a greater variety of symbols.
  4. A student says, “Unicode is only ASCII with emoji added.” Explain why this statement is incomplete.
  5. Explain why a multilingual database should preserve the original characters in a person's name rather than replacing unsupported characters with approximate Latin letters.
Check selected answers
  1. Hi uses the denary character-code sequence 72, 105.
  2. The codes 67, 83 and 33 represent C, S and !, producing CS!.
  3. Seventy characters require seven bits because six bits provide only 64 patterns, whereas seven bits provide 128.
  4. Six bits provide 26 = 64 possible fixed-width codes.

Review

Key ideas

  • Text characters must be represented by numeric codes.
  • A character set maps supported characters to agreed code values.
  • The numeric codes can be stored and processed in binary.
  • A message is stored as an ordered sequence of character codes.
  • Uppercase letters, lowercase letters, digits and punctuation have separate codes.
  • ASCII supports a relatively small core collection of characters.
  • Unicode supports characters from many languages and a much wider symbol range.
  • Unicode code points identify characters using values such as U+5B66.
  • The intended encoding must be used when character data is decoded.
  • Unicode may require more data than basic ASCII because of its wider range.

Quick self-check

  1. Can I explain why text must be converted to numeric codes?
  2. Can I describe the role of a character set?
  3. Can I distinguish a visible character from its stored code?
  4. Can I compare the character ranges of ASCII and Unicode?
  5. Can I explain why multilingual systems need Unicode?
  6. Can I decode a short sequence of ASCII values?

One-minute exit task

Explain why Unicode is more suitable than basic ASCII for a messaging platform used by students in many countries.