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 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.
A person enters a letter, digit, symbol or other text character.
The character set provides the number assigned to that character.
The numeric code is represented using bits so that it can be stored.
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.
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 |
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:
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.
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.
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.
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
- Define the term character set.
- Explain how a character such as K can be stored as binary.
- State three categories of character included in ASCII besides uppercase letters.
- Explain why uppercase A and lowercase a require different character codes.
- The ASCII code for H is 72 and the ASCII code for i is 105. Write the denary code sequence for Hi.
- Convert the ASCII denary codes 67, 83 and 33 into characters.
- Explain one limitation of using only basic ASCII in an international messaging system.
- Explain why Unicode is suitable for storing student names from many countries.
- Describe one similarity and one difference between ASCII and Unicode.
- Explain why a space needs its own character code even though it is not visibly printed.
- A text file is decoded using different rules from those used when it was encoded. Describe a possible consequence.
- Explain why the text character “7” and the numerical value 7 should not automatically be treated as the same stored value.
Extension questions
- A custom character set contains 70 different characters. Determine the minimum number of bits required for one fixed-width character code.
- A system uses six bits for every character. Calculate the maximum number of different character codes available.
- Explain why adding more available bit patterns allows a character set to represent a greater variety of symbols.
- A student says, “Unicode is only ASCII with emoji added.” Explain why this statement is incomplete.
- 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
- Hi uses the denary character-code sequence 72, 105.
- The codes 67, 83 and 33 represent C, S and !, producing CS!.
- Seventy characters require seven bits because six bits provide only 64 patterns, whereas seven bits provide 128.
- 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
- Can I explain why text must be converted to numeric codes?
- Can I describe the role of a character set?
- Can I distinguish a visible character from its stored code?
- Can I compare the character ranges of ASCII and Unicode?
- Can I explain why multilingual systems need Unicode?
- 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.