Here's a preview from my zine, How Integers and Floats Work! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
read the transcript!
panel 1: a string is an array of bytes
ASCII is the simplest string encoding: 1 character = 1 byte. Let’s see how it works!
(We usually use UTF-8, which is WAY more complicated)
panel 2: every printable ASCII character
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\
[]^_`abcdefghijklmnopqrstuvwxyz{|}~
There are no accents because it’s an English encoding: the “A” in ASCII is for “American”.
panel 3: there are 128 ASCII characters
Only the bytes 0 to 127 are defined.
It’s very limited: you can really see why we need more powerful encodings like UTF-8!
panel 4: how bytes map to characters
Here’s a partial list, look up “ASCII table” for the full list. Bytes (in base 10) are on the left, characters are on the right.
33 is !, 34 is “
48 is 0, 49 is 1
64 is A, 65 is B
97 is a, 98 is b
panel 5: a trick to translate from lowercase to uppercase
In ASCII, the lowercase letters are 32 more than the uppercase letters. So you can just subtract 32!
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!