1.1.5 Text Representation in Binary
A computer stores text as numbers. A character set assigns an identifying value to each character, and an encoding converts that value into one or more bytes for storage or transmission.
This section compares ASCII, extended ASCII, Unicode, and UTF-8. It also distinguishes a character's identity from the bytes used to represent it.
By the end of this section, you should be able to:
- explain why text requires a character coding system;
- describe the size and purpose of standard ASCII and extended ASCII;
- distinguish a Unicode code point from a character encoding;
- explain why UTF-8 uses a variable number of bytes;
- recognise UTF-8 start-byte and continuation-byte patterns;
- compare the storage needed by different characters.
Exam focus
Use precise language: a character set assigns values to characters, while an encoding specifies how those values are stored as bytes.
From Character to Binary
Text contains letters, digits, punctuation, spacing characters, and control instructions. A computer needs an agreed mapping so that the same stored value is interpreted consistently.
Character encoding: a rule for representing those values using bytes.
A three-stage model
| Stage | Example | Purpose |
|---|---|---|
| Character | Ξ© | The symbol a person reads. |
| Code point | U+03A9 | The Unicode identifier assigned to the character. |
| Encoded bytes | CE A9 in UTF-8 | The bytes stored or transmitted. |
Common misconception
The visual shape of a character is not stored as text. Its code is stored. A font later determines how the character is drawn on screen or paper.
Standard ASCII
Standard ASCII uses 7 bits, giving 27 = 128 possible codes. It was designed mainly for basic English text, punctuation, digits, and control purposes.
When an ASCII value is stored in an 8-bit byte, the unused most significant bit is normally 0.
| Character | Hexadecimal code | 8-bit storage |
|---|---|---|
| H | 48 | 01001000 |
| i | 69 | 01101001 |
| ? | 3F | 00111111 |
| Space | 20 | 00100000 |
Worked example: storing βHi?β
Each character is encoded independently:
H β 01001000
i β 01101001
? β 00111111
The complete three-character message therefore needs three bytes in ASCII.
Text digit or numeric value?
The character "5" and the numeric value 5 serve different purposes. Text "5" uses a character code; numeric 5 is stored as a number for arithmetic.
Exam tip
You normally need to know the size and purpose of ASCII, not memorise an entire code table.
Extended ASCII
Extended ASCII uses all 8 bits, allowing 28 = 256 code values. The extra values can represent additional symbols or accented letters.
| Feature | Standard ASCII | Extended ASCII |
|---|---|---|
| Bits used | 7 | 8 |
| Possible codes | 128 | 256 |
| Main strength | Consistent basic English set | More regional symbols and letters |
| Main limitation | Very limited language coverage | Different code pages may disagree |
Common misconception
βExtended ASCIIβ does not refer to one single universal set of 256 characters. Different 8-bit code pages may assign different meanings to values above 127.
Unicode
Unicode provides a shared numbering system for characters used across many languages, technical fields, and symbol collections.
| Character | Code point | Description |
|---|---|---|
| Ξ© | U+03A9 | Greek capital omega |
| ζ°΄ | U+6C34 | Chinese character meaning water |
| β¬ | U+20AC | Euro sign |
| π | U+1F600 | Emoji |
Unicode is not the same as UTF-8
Unicode identifies characters. UTF-8 is one method for turning Unicode code points into bytes.
UTF-8
UTF-8 is a variable-length Unicode encoding. A character can use one, two, three, or four bytes. The opening bits indicate the role of each byte.
| Byte count | Pattern | Interpretation |
|---|---|---|
| 1 | 0xxxxxxx | Single-byte character |
| 2 | 110xxxxx 10xxxxxx | Start byte plus one continuation byte |
| 3 | 1110xxxx 10xxxxxx 10xxxxxx | Start byte plus two continuation bytes |
| 4 | 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx | Start byte plus three continuation bytes |
Comparing UTF-8 byte lengths
| Character | Code point | UTF-8 bytes | Storage |
|---|---|---|---|
| H | U+0048 | 48 | 1 byte |
| Ξ© | U+03A9 | CE A9 | 2 bytes |
| ζ°΄ | U+6C34 | E6 B0 B4 | 3 bytes |
| π | U+1F600 | F0 9F 98 80 | 4 bytes |
How to recognise a continuation byte
A UTF-8 continuation byte begins with 10. The first byte indicates how many bytes belong to the character.
Common mistake
One character does not always equal one byte. That is true for ASCII characters in UTF-8, but many other characters require multiple bytes.
Interactive: ASCII and Character Code Explorer
Type one character to inspect its denary, hexadecimal, and binary values.
Interactive: UTF-8 Byte Structure Visualiser
Select a character and follow how UTF-8 divides its stored representation into bytes.
Practice and Review
Try these questions
- Explain why a computer needs an agreed character set.
- State the number of codes available in 7-bit ASCII.
- Compare standard ASCII with extended ASCII.
- Explain the difference between a Unicode code point and UTF-8 bytes.
- Identify the UTF-8 byte count from each prefix:
0,110,1110, and11110. - Explain how a decoder recognises a continuation byte.
- Explain why the text character "5" is not stored in the same way as numeric 5.
Final checklist
- Use the correct number of bits for ASCII.
- Separate character identity from byte encoding.
- Mention variable-length storage for UTF-8.
- Use the prefix 10 when explaining continuation bytes.