A-level Computing/AQA/Fundamentals of data representation/ASCII and unicode



 ASCII normally uses 8 bits (1 byte) to store each character. However, the 8th bit is used as a check digit, meaning that only 7 bits are available to store each character. This gives ASCII the ability to store a total of 2^7 = 128 different values.

ASCII values can take many forms: Take a look at your keyboard and see how many different keys you have. The number should be 104 for a windows keyboard, or 101 for traditional keyboard. With the shift function valus (a, A; b, B etc.) and recognising that some keys have repeated functionality (two shift keys, the num pad). We roughly have 128 functions that a keyboard can perform.
 * Numbers
 * Letters (capitals and lower case are separate)
 * Punctuation (?/|\£$ etc.)
 * non-printing commands (enter, escape, F1)

If you look carefully at the ASCII representation of each character you might notice some patterns. For example: As you can see, a = 97, b = 98, c = 99. This means that if we are told what value a character is we can easily work out the value of subsequent or prior characters.

Without looking at the ASCII table above! If we are told that the ASCII value for the character '5' is 011 0101, what is the ASCII value for '8'.

We know that '8' is three characters after '5', as 5,6,7,8. This means that the ASCII value of '8' will be three bigger than that for '5': 011 0101 ASCII '5' +     011   011 1000  ASCII '8' Checking above this is the correct value.

If you are worried about making mistakes with binary addition, you can deal with the decimal numbers instead. Take the example where you are given the ASCII value of 'g', 110 0111, what is 'e'?

We know that 'e' is two characters before 'g', as e, f, g. This means that the ASCII value of 'e' will be two smaller than that for 'g'. 64 32 16 8  4  2  1  1  1  0  0  1  1  1 = 10310 = ASCII value of 'g' 103 - 2 = 10110 64 32 16 8  4  2  1  1  1  0  0  1  0  1 = 10110 = ASCII value of 'e'

88 - as it is 2 characters down in the alphabet

How many ASCII 'characters' does the following piece of text use: Hello Pete, ASCII rocks!

27 or 26. If you said 23 you'd be wrong because you must include the non-printing characters at the end of each line. Each end of line needs a EOL command, and a new line needs a carriage return (CR), making the text like so: Hello Pete,[EOL][CR] ASCII rocks![EOL]

For the Latin alphabet ASCII is generally fine, but what if you wanted to write something in Mandarin, or Hindi? We need another coding scheme!

You might have to use ASCII codes when reading from text files. To see what each ASCII code means we can use the folliwing function  which returns the ASCII code with denary value x.  Try out the following code to see the first 128 characters. What is special about character 10?