-[Craig] In this video, we take a look at how computers represent characters
and we explore the concept of character sets.
(uplifting piano jingle)
We already understand that everything stored in a computer system is stored in binary,
those zeros and ones that represent just two states.
This means that all data including the characters you type on the keyboard
and the emojis you send in text messages must all have their own binary codes.
If each character was represented by only one binary digit,
then it would mean we could only store two possible characters, perhaps A and B.
If we had two bits for each character then we could store four possible characters
because zero zero might be A,
zero one B, one zero C,
and one one D.
Given that there are 26 letters in our alphabet,
this means that we need 5 bits as a minimum, which will allow us up to 32 characters.
We can express the number of bits to characters mathematically.
For example, 2 to the power of 5 equals 32.
That's because binary is base-2.
There are two possibilities for each bit, zero or one,
and to the power of five because there are five bits.
This means the number of unique binary combinations for 5 bits is 32,
as each character must have its own unique code.
This determines the number of bits needed to store all the characters in a set.
We call this a character set,
a defined list of characters recognised by the computer hardware and software,
and each character represented by a number.
Of course, there are more than 26 characters we want to be able to store.
There are both upper and lowercase letters,
and that doubles the number of characters we need instantly.
But there's also symbols such as pound signs, brackets and punctuations.
Therefore, we actually need a minimum of seven bits for each character.
That is 128 unique binary numbers, 128 unique characters in the character set.
It is important that every computer is using the same binary number to represent each character.
For example, if my computer uses the code 0-1-0-0-0-0-0-1 to represent the capital letter A,
then your computer must also recognise that same binary sequence as a capital letter A also.
Therefore, character sets are agreed standards,
an agreed way of numbering all the characters that computers use.
In the early days of computer science,
ASCII, or the American Standard Code for Information Interchange,
became an accepted standard.
ASCII was a seven-bit character set.
This means there were two to the power of seven combinations of bits,
which is 128 different combinations,
and therefore, it identified 128 characters and their binary codes or denary equivalents.
This was extended to an eight-bit code called extended ASCII,
which provided for characters from some foreign languages and other useful graphical symbols.
In eight bits, we have two to the power of eight combinations
and therefore, 256 characters.
In ASCII, the numbers 0 to 31 were reserved for special characters and instructions to the computer.
So the recognisable part of the character set started with a space at number 32.
Purely out of interest,
character seven caused your computer to beep.
this was before the days of sound cards,
and character 13 was a new line character,
which is why you often have to use commands like strip in programming
when reading data from files to remove or strip these from the ends of lines of text.
So before we move on, a quick note about other character sets.
The exam board clarification document states students do not need to learn about extended ASCII or Unicode,
although they should be aware that these alternative representations
permit larger character sets to be represented.
So we're going to explore that concept now.
Today, we have thousands of symbols we want to be able to store.
We want a fully international and multilingual character set,
which includes all the characters from every written language,
historical scripts plus more modern characters such as emojis.
These need to also conform to a standard,
and this standard is known as Unicode or universal encoding.
Unicode is implemented in slightly different ways for different purposes.
For example, web pages may use a variant known as UTF-8,
where the first 8 bits are the same as ASCII and the other characters are encoded with 32 bits.
Unicode was originally a 16-bit character set.
Many of the lesser-used Chinese characters that referred to people's names or places were not included,
or ancient symbols that were no longer in use.
It was thought originally these would not be necessary,
but that proved not to be the case.
Unicode was finally extended to a 24-bit character set, so that provides over 16 million different combinations.
In other words, we can store 16 million different characters.
Writing in 24-bit extended Unicode is slow and cumbersome and error-prone,
so hexadecimal is used as an alternative.
6 digits in hex equals 24 bits in binary.
Okay, so here's a quick summary of what we've covered.
Pause the video and take some notes.
(uplifting piano jingle)