☰ خطة العام · تكنولوجيا المعلومات والاتصالات (بالإنجليزية)

Binary, hex and characters

الأسبوع 4 · الوحدة ٦ «تصميم المعلومات» (١): التناظري والرقمي، النظام الثنائي وكمية المعلومات، النظام السداسي عشر، تمثيل الحروف رقميًا · 3 دروس
3

How a computer stores letters

ICT Secondary 1 Term 1, Chapter 6, Lessons 6-1 to 6-4: pp. 53–64
GoalExplain how characters are stored as numbers and why the wrong code table gives garbled text.
New words
character code · the number given to a character in a code tableASCII · an older 7-bit table for English letters, digits and signsUnicode · one table with a number for the characters of all scriptsfont · the look of the letters on the screen
Explanation

A computer stores only numbers, so every character has a number in a code table. In ASCII, a table with 7 bits, so 128 codes, the capital letter A is 65, B is 66 and so on; the small letter a is 97, the digit character 0 is 48 and the space is 32. A byte has 256 values, but ASCII uses only 128 of them. Note that the character 7 has code 55, while the number 7 is stored as 0000 0111: the character and the number are different things. ASCII has no Arabic letters, so people made other tables, and the same number meant different characters in different tables. If a text written with one table is opened with another, you see garbled text. Unicode solves this: it is one table that gives a number to the characters of all scripts, including Arabic, so a text can mix languages. For example, the Arabic letter alef is 0627 in hex, which is 1575 in decimal. A font is only the look of the character, its shape and style; changing the font never changes the code. Remember: the code says which character, the font says how it looks.

ABC
1CharacterCode (decimal)Code (7 bits)
2A651000001
3B661000010
4C671000011
5a971100001
60480110000
7space320100000
Worked examples
Write CAB as codes: C = 67, A = 65, B = 66, so the codes are 67 65 66. To decode 72 73, count from A = 65: 72 is 7 after A, which is H; 73 is I. So 72 73 is HI.
StepWhat happens
writersaves the text with table 1
readeropens it with table 2
resultsame numbers, other characters: garbled text
Two tables can give the same number different characters. A text made with table 1 and opened with table 2 turns into strange symbols, as when two people use different keys for one lock. Unicode avoids this with one shared table.
Class activity

Write your first name in capital Latin letters, then write the code of each letter, counting from A = 65. Then write the same codes in binary with 7 bits. Do not use anyone else’s name.

Practice
1
What is the code of the letter D if A = 65?
2
How many different codes does 7-bit ASCII have?
3
Does a new font change the code of a letter? Explain.
4
Why can Unicode show Arabic and English in one text?