We already know that computers hold data using binary, so representing characters requires the computer to convert from alphanumeric (letters & numbers as text) into binary.
So how do you convert a letter into binary? The simple answer is that you can’t. Instead, each character is assigned a number value which is stored in a table known as a.
There are two main character sets, both of which are discussed at GCSE. The first of these is ASCII (as-key), American Standard Code for Information Interchange.
One of the questions often asked in an exam is how many characters can ASCII represent. We can calculate this by knowing that it uses 7 bits of binary data to represent each character:
The maximum binary number with 7 bits is: 1111111
1111111 = 127
127 + 1 = 128
Why the +1? Because 0 is a number!
As digital representation gre, people wanted to be able to show a variety of languages in their documents which required different characters. Unforunately ASCII has a limitation on what it can represent with so few characters so an alternative had to be found. The Unicode character set was implemented with a much greater capacity, using 16 bits to represent each character.
With 16 bits, the capacity was enough to represent all possible alphabets and still have enough room to save emojis
16 bits = 1111 1111 1111 1111
+ 1 = 65,356 characters!
Being aware that each ASCII character has a number attached, and these numbers are linear can help to improve the efficiency of our programs.
Consider the challenge below: A user must enter their name, using the syntax rules of the English Language (must start with a capital letter, and the rest must be lower case letters). If the name does not meet these rules, the user should be prompted to try again.
We could set up alphabet arrays, or we could make the computer do the hard work by using two very useful built in programming functions:
ORD () – changes a character to it’s ASCII number
CHR() – changes a number to it’s ASCII character
In the program below, the first character has been coded for you. Try extending the program so that the whole input is checked:
The Character Sets Scribbl.it Notes provide a structured way for students to revise topic areas covered in class in a visual way. Encourage students to colour in areas of importance, add doodles and colour, then add more detail to the notes page being as creative as possible.