ASCII
What is it
American Standard Code for Information Interchange
ASCII
is a standard data encoding
format for electronic communication between computers.
ASCII
is about convertingbinary number
to anumeric value
to acharacter
orinstruction
These are arbitrary mappings of numeric value
to a human-readable character
- Read further section on
IBM
vsMac
extended characters
This is in contrast to hexadecimal
which is a sequential (less arbitrary) mapping of bits/bytes
to a more human-legible format (0-9
, then A-F
)
Original ASCII
Original ASCII
was a 7-bit
code
2^7
=128 possible characters
1 bit
was reserved bit for parity (way to look for errors)
First 0
to 31
were reserved as control characters
First character 32
represents blank space ( )
Last character 126
represents tilde (~)
Control characters
are invisible (not printed on screen) characters that serve as instructions to peripherals such as printers or screens
Extended Characters
Modern ASCII
uses extended character sets
which uses all 8-bit
allocation to double the number of characters:
2^8
=256 possible characters
IBM
and Mac
created their own extended character sets (because they were competitors), leading to diverging definition of extended character sets
130
was used for accentede
on Windows/Dos while Macs used142
What is ASCII
's relationship to binary number
and decimal number
Let's take typing on a keyboard as an example.
A keypress on a keyboard sends a very low voltage signal which is picked up by the I/O system on motherboard.
The I/O handler then sends the signal to the interrupt handler, which sends it as a keyboard interrupt to the operating system's keyboard driver.
The keyboard driver maps this high-priority interrupt signal to a binary value according to hardware's specific rules.
This binary representation
of a keypress
is what the operating system
uses or sends to another program
When you press a g
and h
key, two voltages get translated to binary values
of 0110 0111
and 0100 1000
.
- These values translate to
decimal representation
of103
and72
The ASCII
code is a mapping between the binary representation
to a decimal numeric value
and a corresponding symbol
which the computer paints on the screen.
Since hexadecimal
can also represent binary number
, you can also map ASCII
to hexadecimal
representation