StudyVault
Home Unit Overview Exam Technique Revision Techniques ← Previous Lesson Next Lesson →

← Back to Dashboard

Overlay:
0:00 / 0:00 Narration generated using AI text-to-speech.

Character Encoding: ASCII and Unicode

How Computers Store Text

A computer stores everything as binary — including the letters you type. To do this, every character must be assigned a unique number, which is then stored as its binary equivalent. A character set is the agreed list that maps each character to its code. Without a shared standard, a file created on one computer would display as gibberish on another.

ASCII: The 7-Bit Standard

ASCII (American Standard Code for Information Interchange) was developed to give early computers a common language for text. It uses 7 bits per character, which allows for 27 = 128 unique codes (0 to 127). These 128 characters cover the upper-case English alphabet, the lower-case English alphabet, the digits 0–9, punctuation marks, and a set of control characters (such as “new line”).

The key principle behind ASCII is that codes are grouped and sequential. The upper-case letters run consecutively: A = 65, B = 66, C = 67, and so on up to Z = 90. The lower-case letters start at a = 97, b = 98, and continue to z = 122. The digit characters begin at 0 = 48, 1 = 49, and continue to 9 = 57. This means that if you know the code for one character in a group, you can calculate the code for any other in that group by counting up or down.

Key Fact

In ASCII: upper-case A = 65, lower-case a = 97, digit 0 = 48. Because codes are sequential within each group, you can calculate any character’s code: ‘F’ = 65 + 5 = 70. ‘n’ = 97 + 13 = 110. ASCII uses 7 bits and covers 128 characters (0–127).

Example 1: Given that A = 65, what is the code for G?
G is the 7th letter (A=1, B=2, C=3, D=4, E=5, F=6, G=7).
G = 65 + (7 − 1) = 65 + 6 = 71

Example 2: A character has the ASCII code 100. What character is it?
Lower-case a = 97. 100 − 97 = 3. Count 3 letters on from a: b, c, d.
The character is ‘d’.

Example 3: Given that digit 0 = 48, what code represents the character ‘7’?
7 is 7 positions after 0: 48 + 7 = 55.
Note: ‘7’ as a character (code 55) is different from the integer 7 (the value itself). This distinction matters when sorting or comparing strings.

The Limitation of ASCII

With only 128 characters, ASCII has no space for accented letters (é, ñ, ü), Chinese or Arabic script, mathematical symbols beyond basic operators, or the emoji that modern communication relies on. As the internet connected the world, it became impossible to exchange text between different languages using ASCII alone. A website serving users in Japan, Saudi Arabia and Nigeria cannot represent all three languages in 7 bits.

Unicode: A Universal Standard

Unicode was developed to solve ASCII’s limitations. Rather than 7 bits, Unicode uses more bits per character, allowing for far more than 128 code points. The Unicode standard can represent over one million distinct characters — enough for every writing system currently in use, historical scripts, mathematical symbols, scientific notation, and emoji.

An important design decision was that Unicode is backwards-compatible with ASCII: it uses exactly the same codes as ASCII for the first 128 characters (0–127). This means that any file stored using ASCII can be read by a Unicode system without any conversion. The letter A is still code 65 in Unicode, just as it is in ASCII.

Key Fact

Unicode uses the same codes as ASCII for characters 0–127, but extends far beyond to cover every writing system in use worldwide. This backwards-compatibility means ASCII files are readable by any Unicode system without conversion. Unicode can represent over one million characters; ASCII can only represent 128.

Comparing ASCII and Unicode

ASCII uses 7 bits per character and covers 128 characters. This is sufficient for English-language text and simple punctuation, and it uses less storage per character. Unicode uses more bits per character to support a vastly larger range of code points. The trade-off is that Unicode files require more storage space per character than ASCII files for the same English text. However, this cost is negligible on modern hardware, and the ability to represent all the world’s languages in a single standard is worth it. Virtually every modern operating system, browser, and application uses Unicode.

You do not need to know the details of specific Unicode formats such as UTF-8 or UTF-16 for this course. Understanding that Unicode uses more bits than ASCII, supports far more characters, and remains backwards-compatible with ASCII codes 0–127 is what the exam requires.

Because character codes are sequential and grouped, computers can sort text alphabetically by comparing character codes numerically. ‘A’ (65) comes before ‘B’ (66) because 65 < 66. All upper-case letters (65–90) come before all lower-case letters (97–122), which is why a list sorted by character code puts ‘Z’ before ‘a’. This is called lexicographic order and it is how search engines, databases and spreadsheets perform string comparisons.

It is also why you must be careful when comparing user input: the string “7” (character code 55) is not the same as the integer 7 (value 7). A sort on string values would place “10” before “9” because ‘1’ (49) < ‘9’ (57) — another common programming mistake that character encoding helps explain.

Practice Questions

Test yourself on this lesson. Pick a question, write your answer, then get it marked.

AI feedback
AI feedback is guidance, not a final exam mark. If you disagree, your teacher's view is always the tie-breaker.
← Back to unit
Video

© 2026 StudyVault · About · FAQ · Copyright & IP · Privacy · Disclaimers

StudyVault Education Ltd · registered in England and Wales, company no. 17490559 · 71–75 Shelton Street, London WC2H 9JQ