Intro to Computer Science / Unit 2: Binary and Data Representation
2.3 Bits, Bytes and Text
Notes
Text is stored by giving each character a number, then storing that number in binary.
- ASCII uses 7 bits (usually stored in 8) to represent 128 characters: letters, digits and punctuation.
- In ASCII, 'A' is 65, 'B' is 66, 'a' is 97 and '0' is 48. A lowercase letter is its uppercase letter plus 32.
- Unicode is a much larger standard that includes characters from many languages and emoji. UTF-8 is a common way to store it.
- Example: the word "Hi" is stored as the numbers 72 and 105.
- A character in ASCII takes 1 byte, so a 100-character message needs about 100 bytes.
Practice
In ASCII, 'A' is 65. What is 'C'?
Letters are numbered in order: A=65, B=66, C=67.
Why was Unicode created?
ASCII covers only 128 characters. Unicode supports far more.
Using 1 byte per character, about how many bytes does the text "good morning" (12 characters with the space) need?
One byte per character gives 12 bytes.
Ready for more? Take the Unit 2 test.