# ASCII: a working reference ASCII is the character encoding that almost everything else is built on top of. It defines 128 code points, numbered 0 to 127, and it has not changed since 1986. Learn it once and you have the bottom layer of text handling in every language, every protocol and every file format you will meet on a computer science course. This page is the whole standard plus the parts that matter in practice: the tables, the bit tricks, the control characters nobody explains, the extended 8-bit code pages that came after, and how all of it relates to Unicode and UTF-8. > **Interactive:** the web version of this page at https://ascii.mikeashfield.co.uk has a reverse lookup box here. > It accepts a character, a number in any base, a name, an abbreviation or a keystroke > such as `^C`. The tables below contain the same data. - [Quick answers](#quick-answers) - [The chart](#the-chart) - [How ASCII is laid out](#how-ascii-is-laid-out) - [Seven bits, 128 code points](#seven-bits-128-code-points) - [The four columns of 32](#the-four-columns-of-32) - [The case bit](#the-case-bit) - [The digit trick](#the-digit-trick) - [The control key trick](#the-control-key-trick) - [The full tables](#the-full-tables) - [Control characters: 0-31 and 127](#control-characters-0-31-and-127) - [Codes 32-63: space, punctuation and digits](#codes-32-63-space-punctuation-and-digits) - [Codes 64-95: uppercase and symbols](#codes-64-95-uppercase-and-symbols) - [Codes 96-127: lowercase, symbols and DEL](#codes-96-127-lowercase-symbols-and-del) - [Control characters explained](#control-characters-explained) - [Line endings, the one that actually bites](#line-endings-the-one-that-actually-bites) - [The four separators nobody uses](#the-four-separators-nobody-uses) - [Characters that are whitespace](#characters-that-are-whitespace) - [Printable characters worth knowing](#printable-characters-worth-knowing) - [Converting between representations](#converting-between-representations) - [Doing it by hand](#doing-it-by-hand) - [Doing it in code](#doing-it-in-code) - [Beyond 7 bits: the extended code pages](#beyond-7-bits-the-extended-code-pages) - [ISO 8859-1, also called Latin-1](#iso-8859-1-also-called-latin-1) - [Windows-1252](#windows-1252) - [Code page 437](#code-page-437) - [ASCII and Unicode](#ascii-and-unicode) - [UTF-8](#utf-8) - [Encoding a file, and what goes wrong](#encoding-a-file-and-what-goes-wrong) - [Escape sequences](#escape-sequences) - [ANSI escape codes](#ansi-escape-codes) - [Colours and styles](#colours-and-styles) - [Cursor and screen control](#cursor-and-screen-control) - [Practical gotchas](#practical-gotchas) - [Where ASCII shows up](#where-ascii-shows-up) - [Base64](#base64) - [Percent encoding in URLs](#percent-encoding-in-urls) - [Regular expression character classes](#regular-expression-character-classes) - [Other places it hangs around](#other-places-it-hangs-around) - [A short history](#a-short-history) - [Glossary](#glossary) - [Further reading](#further-reading) ## Quick answers The four numbers worth memorising: | Character | Decimal | Hex | Binary | Handy because | | --- | ---: | ---: | --- | --- | | `0` | 48 | `30` | `0011 0000` | `c - '0'` turns a digit character into its value | | `A` | 65 | `41` | `0100 0001` | Start of the uppercase run | | `a` | 97 | `61` | `0110 0001` | Start of the lowercase run, exactly 32 above `A` | | space | 32 | `20` | `0010 0000` | Lowest printable code, so it sorts before everything visible | Everything else can be derived. `Z` is `A` plus 25, so 90. `z` is 122. `9` is 57. The letters and digits are each one unbroken run, which is why range checks such as `c >= 'a' && c <= 'z'` are correct in ASCII (and why they are not correct in EBCDIC, where the alphabet has gaps). **The whole table in ten rows** | Range | Dec | Hex | Binary pattern | Contents | | --- | ---: | ---: | --- | --- | | Control | 0-31 | 00-1F | 000xxxxx / 0001xxxx | Non-printing commands | | Space | 32 | 20 | 0010 0000 | The only printable whitespace | | Punctuation | 33-47 | 21-2F | 0010xxxx | ! " # $ % & ' ( ) * + , - . / | | Digits | 48-57 | 30-39 | 0011 xxxx | 0 to 9, low nibble is the value | | Punctuation | 58-64 | 3A-40 | 0011/0100 | : ; < = > ? @ | | Uppercase | 65-90 | 41-5A | 010xxxxx | A to Z | | Punctuation | 91-96 | 5B-60 | 0101/0110 | [ \ ] ^ _ ` | | Lowercase | 97-122 | 61-7A | 011xxxxx | a to z | | Punctuation | 123-126 | 7B-7E | 0111 11xx | { \| } ~ | | Delete | 127 | 7F | 0111 1111 | DEL, all seven bits set | > **Reading this page offline** > > The whole reference is also published as plain Markdown at > [ascii-reference.md](ascii-reference.md), including every table below. Individual tables have a > **Copy as Markdown** button, and the page is styled to print cleanly to paper or PDF. ## The chart The classic layout. Read a code point by combining its column (the high 3 bits) with its row (the low 4 bits), so `K` sits in column 4, row B, which is `0x4B`, decimal 75. Every structural property of ASCII is visible in this grid: the two control columns on the left, the two letter columns with uppercase directly above lowercase, and the digits stacked in column 3. **ASCII at a glance: column = high 3 bits, row = low 4 bits** | Low nibble | High 0 (000) | High 1 (001) | High 2 (010) | High 3 (011) | High 4 (100) | High 5 (101) | High 6 (110) | High 7 (111) | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | **0** | NUL 0 | DLE 16 | SP 32 | 0 48 | @ 64 | P 80 | ` 96 | p 112 | | **1** | SOH 1 | DC1 17 | ! 33 | 1 49 | A 65 | Q 81 | a 97 | q 113 | | **2** | STX 2 | DC2 18 | " 34 | 2 50 | B 66 | R 82 | b 98 | r 114 | | **3** | ETX 3 | DC3 19 | # 35 | 3 51 | C 67 | S 83 | c 99 | s 115 | | **4** | EOT 4 | DC4 20 | $ 36 | 4 52 | D 68 | T 84 | d 100 | t 116 | | **5** | ENQ 5 | NAK 21 | % 37 | 5 53 | E 69 | U 85 | e 101 | u 117 | | **6** | ACK 6 | SYN 22 | & 38 | 6 54 | F 70 | V 86 | f 102 | v 118 | | **7** | BEL 7 | ETB 23 | ' 39 | 7 55 | G 71 | W 87 | g 103 | w 119 | | **8** | BS 8 | CAN 24 | ( 40 | 8 56 | H 72 | X 88 | h 104 | x 120 | | **9** | HT 9 | EM 25 | ) 41 | 9 57 | I 73 | Y 89 | i 105 | y 121 | | **A** | LF 10 | SUB 26 | * 42 | : 58 | J 74 | Z 90 | j 106 | z 122 | | **B** | VT 11 | ESC 27 | + 43 | ; 59 | K 75 | [ 91 | k 107 | { 123 | | **C** | FF 12 | FS 28 | , 44 | < 60 | L 76 | \ 92 | l 108 | \\| 124 | | **D** | CR 13 | GS 29 | - 45 | = 61 | M 77 | ] 93 | m 109 | } 125 | | **E** | SO 14 | RS 30 | . 46 | > 62 | N 78 | ^ 94 | n 110 | ~ 126 | | **F** | SI 15 | US 31 | / 47 | ? 63 | O 79 | _ 95 | o 111 | DEL 127 | ## How ASCII is laid out ### Seven bits, 128 code points ASCII is a 7-bit code. That is the single most important fact about it, and it explains the size of the table: 2 to the power 7 is 128, so the valid code points are 0 to 127 and nothing else. Seven bits was a deliberate compromise. Six bits (64 characters) could not hold both cases of the alphabet plus digits and punctuation. Eight bits would have been wasteful on hardware where a character cost real money to store and transmit, and the eighth bit was wanted anyway: serial links used it as a **parity bit** for error detection. The consequence you will hit in code is that a byte can hold values 128 to 255 that are not ASCII at all. "Extended ASCII" is not a standard, it is a family of mutually incompatible guesses about what those extra 128 values mean. See [Beyond 7 bits](#beyond-7-bits-the-extended-code-pages). ### The four columns of 32 Split the table into four blocks of 32 and the design becomes obvious: | Block | Range | Top 2 bits | Contents | | --- | ---: | --- | --- | | 0 | 0-31 | `00` | Control characters | | 1 | 32-63 | `01` | Space, punctuation, digits | | 2 | 64-95 | `10` | `@`, uppercase A-Z, a few symbols | | 3 | 96-127 | `11` | Backtick, lowercase a-z, a few symbols, DEL | Block 2 and block 3 are the same block with one bit changed. Block 0 is block 1 or block 2 with the top bits cleared. None of this is coincidence, and all of it is exploitable. ### The case bit Bit 5, worth 32, is the only difference between an uppercase letter and its lowercase partner: ```text A = 0100 0001 = 65 a = 0110 0001 = 97 ^ bit 5, value 32 ``` So for letters only: ```c c | 0x20 /* force lowercase */ c & ~0x20 /* force uppercase, that is c & 0xDF */ c ^ 0x20 /* swap the case */ ``` > **This only works for letters** > > `0x20` flips the case bit of anything, so applying it to `[` (91) gives `{` (123) and applying it > to `4` gives the code for the DC4 control character. Always guard the operation with a range > check, or just call `toupper` and `tolower`, which handle the check and the current locale for > you. The trick is worth knowing because you will see it in other people's code and in exam > questions, not because you should scatter it through your own. The same 32 gap explains a subtler thing: because uppercase letters all have smaller code points than lowercase ones, a plain byte-order sort puts `Zebra` before `apple`. That is ASCIIbetical order, and it is not alphabetical order. Case-insensitive sorting is a deliberate extra step. ### The digit trick Digits occupy 48 to 57, and their low four bits are the value of the digit: ```text '0' = 0011 0000 = 48 low nibble 0000 = 0 '7' = 0011 0111 = 55 low nibble 0111 = 7 '9' = 0011 1001 = 57 low nibble 1001 = 9 ``` Which gives the two conversions you will write a hundred times: ```c int value = c - '0'; /* character to number */ char digit = n + '0'; /* number to character */ ``` That is the entire body of a simple `atoi`, and it is why `c & 0x0F` also works on a digit. Hexadecimal needs one extra step, because the letters are not adjacent to the digits: ```c int hexval(char c) { if (c >= '0' && c <= '9') return c - '0'; if (c >= 'a' && c <= 'f') return c - 'a' + 10; if (c >= 'A' && c <= 'F') return c - 'A' + 10; return -1; } ``` ### The control key trick Control characters are not an arbitrary list bolted on to the front of the table. A control character is its printable partner with the top two bits cleared, which in hardware terms is what the Ctrl key on a terminal keyboard physically did: ```text C = 0100 0011 = 67 ^C = 0000 0011 = 3 (ETX) ``` So `Ctrl` plus a key gives you `key & 0x1F`, or equivalently `key - 64` for uppercase letters. Read the table the other way and every control character has an obvious keystroke: - `Ctrl+I` is 9, which is Tab. Tab and `Ctrl+I` are literally the same byte, which is why they are interchangeable in a terminal. - `Ctrl+M` is 13, carriage return, which is what the Enter key sends. - `Ctrl+[` is 27, Escape. - `Ctrl+H` is 8, backspace. This is also why terminal shortcuts cluster where they do. `Ctrl+C`, `Ctrl+D`, `Ctrl+S` and `Ctrl+Z` all have their behaviour because of what the corresponding control character meant. > **Interactive:** the web version has a clickable bit inspector here, for flipping > individual bits and watching the character change. ## The full tables Four tables of 32 rows, matching the four blocks above. Every code point in ASCII appears exactly once across them. ### Control characters: 0-31 and 127 **33 codes, with the keystroke that sends each one** | Dec | Hex | Oct | Binary | Abbr | Name | Caret | C escape | | ---: | ---: | ---: | --- | --- | --- | --- | --- | | 0 | `00` | `000` | `00000000` | `NUL` | Null | `^@` | `\0` | | 1 | `01` | `001` | `00000001` | `SOH` | Start of Heading | `^A` | none | | 2 | `02` | `002` | `00000010` | `STX` | Start of Text | `^B` | none | | 3 | `03` | `003` | `00000011` | `ETX` | End of Text | `^C` | none | | 4 | `04` | `004` | `00000100` | `EOT` | End of Transmission | `^D` | none | | 5 | `05` | `005` | `00000101` | `ENQ` | Enquiry | `^E` | none | | 6 | `06` | `006` | `00000110` | `ACK` | Acknowledge | `^F` | none | | 7 | `07` | `007` | `00000111` | `BEL` | Bell | `^G` | `\a` | | 8 | `08` | `010` | `00001000` | `BS` | Backspace | `^H` | `\b` | | 9 | `09` | `011` | `00001001` | `HT` | Horizontal Tab | `^I` | `\t` | | 10 | `0A` | `012` | `00001010` | `LF` | Line Feed | `^J` | `\n` | | 11 | `0B` | `013` | `00001011` | `VT` | Vertical Tab | `^K` | `\v` | | 12 | `0C` | `014` | `00001100` | `FF` | Form Feed | `^L` | `\f` | | 13 | `0D` | `015` | `00001101` | `CR` | Carriage Return | `^M` | `\r` | | 14 | `0E` | `016` | `00001110` | `SO` | Shift Out | `^N` | none | | 15 | `0F` | `017` | `00001111` | `SI` | Shift In | `^O` | none | | 16 | `10` | `020` | `00010000` | `DLE` | Data Link Escape | `^P` | none | | 17 | `11` | `021` | `00010001` | `DC1` | Device Control 1 | `^Q` | none | | 18 | `12` | `022` | `00010010` | `DC2` | Device Control 2 | `^R` | none | | 19 | `13` | `023` | `00010011` | `DC3` | Device Control 3 | `^S` | none | | 20 | `14` | `024` | `00010100` | `DC4` | Device Control 4 | `^T` | none | | 21 | `15` | `025` | `00010101` | `NAK` | Negative Acknowledge | `^U` | none | | 22 | `16` | `026` | `00010110` | `SYN` | Synchronous Idle | `^V` | none | | 23 | `17` | `027` | `00010111` | `ETB` | End of Transmission Block | `^W` | none | | 24 | `18` | `030` | `00011000` | `CAN` | Cancel | `^X` | none | | 25 | `19` | `031` | `00011001` | `EM` | End of Medium | `^Y` | none | | 26 | `1A` | `032` | `00011010` | `SUB` | Substitute | `^Z` | none | | 27 | `1B` | `033` | `00011011` | `ESC` | Escape | `^[` | `\e` | | 28 | `1C` | `034` | `00011100` | `FS` | File Separator | `^\` | none | | 29 | `1D` | `035` | `00011101` | `GS` | Group Separator | `^]` | none | | 30 | `1E` | `036` | `00011110` | `RS` | Record Separator | `^^` | none | | 31 | `1F` | `037` | `00011111` | `US` | Unit Separator | `^_` | none | | 127 | `7F` | `177` | `01111111` | `DEL` | Delete | `^?` | none | ### Codes 32-63: space, punctuation and digits **The space, 15 punctuation marks, the ten digits and six more** | Dec | Hex | Oct | Binary | Char | Name | HTML | Type | | ---: | ---: | ---: | --- | :---: | --- | --- | --- | | 32 | `20` | `040` | `00100000` | `SP` (space) | Space | ` ` | Whitespace | | 33 | `21` | `041` | `00100001` | `!` | Exclamation Mark | `!` | Punctuation | | 34 | `22` | `042` | `00100010` | `"` | Quotation Mark | `"` | Punctuation | | 35 | `23` | `043` | `00100011` | `#` | Number Sign | `#` | Punctuation | | 36 | `24` | `044` | `00100100` | `$` | Dollar Sign | `$` | Punctuation | | 37 | `25` | `045` | `00100101` | `%` | Percent Sign | `%` | Punctuation | | 38 | `26` | `046` | `00100110` | `&` | Ampersand | `&` | Punctuation | | 39 | `27` | `047` | `00100111` | `'` | Apostrophe | `'` | Punctuation | | 40 | `28` | `050` | `00101000` | `(` | Left Parenthesis | `(` | Punctuation | | 41 | `29` | `051` | `00101001` | `)` | Right Parenthesis | `)` | Punctuation | | 42 | `2A` | `052` | `00101010` | `*` | Asterisk | `*` | Punctuation | | 43 | `2B` | `053` | `00101011` | `+` | Plus Sign | `+` | Punctuation | | 44 | `2C` | `054` | `00101100` | `,` | Comma | `,` | Punctuation | | 45 | `2D` | `055` | `00101101` | `-` | Hyphen-Minus | `-` | Punctuation | | 46 | `2E` | `056` | `00101110` | `.` | Full Stop | `.` | Punctuation | | 47 | `2F` | `057` | `00101111` | `/` | Solidus | `/` | Punctuation | | 48 | `30` | `060` | `00110000` | `0` | Digit Zero | `0` | Digit | | 49 | `31` | `061` | `00110001` | `1` | Digit One | `1` | Digit | | 50 | `32` | `062` | `00110010` | `2` | Digit Two | `2` | Digit | | 51 | `33` | `063` | `00110011` | `3` | Digit Three | `3` | Digit | | 52 | `34` | `064` | `00110100` | `4` | Digit Four | `4` | Digit | | 53 | `35` | `065` | `00110101` | `5` | Digit Five | `5` | Digit | | 54 | `36` | `066` | `00110110` | `6` | Digit Six | `6` | Digit | | 55 | `37` | `067` | `00110111` | `7` | Digit Seven | `7` | Digit | | 56 | `38` | `070` | `00111000` | `8` | Digit Eight | `8` | Digit | | 57 | `39` | `071` | `00111001` | `9` | Digit Nine | `9` | Digit | | 58 | `3A` | `072` | `00111010` | `:` | Colon | `:` | Punctuation | | 59 | `3B` | `073` | `00111011` | `;` | Semicolon | `;` | Punctuation | | 60 | `3C` | `074` | `00111100` | `<` | Less-Than Sign | `<` | Punctuation | | 61 | `3D` | `075` | `00111101` | `=` | Equals Sign | `=` | Punctuation | | 62 | `3E` | `076` | `00111110` | `>` | Greater-Than Sign | `>` | Punctuation | | 63 | `3F` | `077` | `00111111` | `?` | Question Mark | `?` | Punctuation | ### Codes 64-95: uppercase and symbols **The at sign, A to Z, and five bracket-family symbols** | Dec | Hex | Oct | Binary | Char | Name | HTML | Type | | ---: | ---: | ---: | --- | :---: | --- | --- | --- | | 64 | `40` | `100` | `01000000` | `@` | Commercial At | `@` | Punctuation | | 65 | `41` | `101` | `01000001` | `A` | Latin Capital Letter A | `A` | Uppercase letter | | 66 | `42` | `102` | `01000010` | `B` | Latin Capital Letter B | `B` | Uppercase letter | | 67 | `43` | `103` | `01000011` | `C` | Latin Capital Letter C | `C` | Uppercase letter | | 68 | `44` | `104` | `01000100` | `D` | Latin Capital Letter D | `D` | Uppercase letter | | 69 | `45` | `105` | `01000101` | `E` | Latin Capital Letter E | `E` | Uppercase letter | | 70 | `46` | `106` | `01000110` | `F` | Latin Capital Letter F | `F` | Uppercase letter | | 71 | `47` | `107` | `01000111` | `G` | Latin Capital Letter G | `G` | Uppercase letter | | 72 | `48` | `110` | `01001000` | `H` | Latin Capital Letter H | `H` | Uppercase letter | | 73 | `49` | `111` | `01001001` | `I` | Latin Capital Letter I | `I` | Uppercase letter | | 74 | `4A` | `112` | `01001010` | `J` | Latin Capital Letter J | `J` | Uppercase letter | | 75 | `4B` | `113` | `01001011` | `K` | Latin Capital Letter K | `K` | Uppercase letter | | 76 | `4C` | `114` | `01001100` | `L` | Latin Capital Letter L | `L` | Uppercase letter | | 77 | `4D` | `115` | `01001101` | `M` | Latin Capital Letter M | `M` | Uppercase letter | | 78 | `4E` | `116` | `01001110` | `N` | Latin Capital Letter N | `N` | Uppercase letter | | 79 | `4F` | `117` | `01001111` | `O` | Latin Capital Letter O | `O` | Uppercase letter | | 80 | `50` | `120` | `01010000` | `P` | Latin Capital Letter P | `P` | Uppercase letter | | 81 | `51` | `121` | `01010001` | `Q` | Latin Capital Letter Q | `Q` | Uppercase letter | | 82 | `52` | `122` | `01010010` | `R` | Latin Capital Letter R | `R` | Uppercase letter | | 83 | `53` | `123` | `01010011` | `S` | Latin Capital Letter S | `S` | Uppercase letter | | 84 | `54` | `124` | `01010100` | `T` | Latin Capital Letter T | `T` | Uppercase letter | | 85 | `55` | `125` | `01010101` | `U` | Latin Capital Letter U | `U` | Uppercase letter | | 86 | `56` | `126` | `01010110` | `V` | Latin Capital Letter V | `V` | Uppercase letter | | 87 | `57` | `127` | `01010111` | `W` | Latin Capital Letter W | `W` | Uppercase letter | | 88 | `58` | `130` | `01011000` | `X` | Latin Capital Letter X | `X` | Uppercase letter | | 89 | `59` | `131` | `01011001` | `Y` | Latin Capital Letter Y | `Y` | Uppercase letter | | 90 | `5A` | `132` | `01011010` | `Z` | Latin Capital Letter Z | `Z` | Uppercase letter | | 91 | `5B` | `133` | `01011011` | `[` | Left Square Bracket | `[` | Punctuation | | 92 | `5C` | `134` | `01011100` | `\` | Reverse Solidus | `\` | Punctuation | | 93 | `5D` | `135` | `01011101` | `]` | Right Square Bracket | `]` | Punctuation | | 94 | `5E` | `136` | `01011110` | `^` | Circumflex Accent | `^` | Punctuation | | 95 | `5F` | `137` | `01011111` | `_` | Low Line | `_` | Punctuation | ### Codes 96-127: lowercase, symbols and DEL **The backtick, a to z, four symbols and DEL** | Dec | Hex | Oct | Binary | Char | Name | HTML | Type | | ---: | ---: | ---: | --- | :---: | --- | --- | --- | | 96 | `60` | `140` | `01100000` | `` ` `` | Grave Accent | ``` | Punctuation | | 97 | `61` | `141` | `01100001` | `a` | Latin Small Letter A | `a` | Lowercase letter | | 98 | `62` | `142` | `01100010` | `b` | Latin Small Letter B | `b` | Lowercase letter | | 99 | `63` | `143` | `01100011` | `c` | Latin Small Letter C | `c` | Lowercase letter | | 100 | `64` | `144` | `01100100` | `d` | Latin Small Letter D | `d` | Lowercase letter | | 101 | `65` | `145` | `01100101` | `e` | Latin Small Letter E | `e` | Lowercase letter | | 102 | `66` | `146` | `01100110` | `f` | Latin Small Letter F | `f` | Lowercase letter | | 103 | `67` | `147` | `01100111` | `g` | Latin Small Letter G | `g` | Lowercase letter | | 104 | `68` | `150` | `01101000` | `h` | Latin Small Letter H | `h` | Lowercase letter | | 105 | `69` | `151` | `01101001` | `i` | Latin Small Letter I | `i` | Lowercase letter | | 106 | `6A` | `152` | `01101010` | `j` | Latin Small Letter J | `j` | Lowercase letter | | 107 | `6B` | `153` | `01101011` | `k` | Latin Small Letter K | `k` | Lowercase letter | | 108 | `6C` | `154` | `01101100` | `l` | Latin Small Letter L | `l` | Lowercase letter | | 109 | `6D` | `155` | `01101101` | `m` | Latin Small Letter M | `m` | Lowercase letter | | 110 | `6E` | `156` | `01101110` | `n` | Latin Small Letter N | `n` | Lowercase letter | | 111 | `6F` | `157` | `01101111` | `o` | Latin Small Letter O | `o` | Lowercase letter | | 112 | `70` | `160` | `01110000` | `p` | Latin Small Letter P | `p` | Lowercase letter | | 113 | `71` | `161` | `01110001` | `q` | Latin Small Letter Q | `q` | Lowercase letter | | 114 | `72` | `162` | `01110010` | `r` | Latin Small Letter R | `r` | Lowercase letter | | 115 | `73` | `163` | `01110011` | `s` | Latin Small Letter S | `s` | Lowercase letter | | 116 | `74` | `164` | `01110100` | `t` | Latin Small Letter T | `t` | Lowercase letter | | 117 | `75` | `165` | `01110101` | `u` | Latin Small Letter U | `u` | Lowercase letter | | 118 | `76` | `166` | `01110110` | `v` | Latin Small Letter V | `v` | Lowercase letter | | 119 | `77` | `167` | `01110111` | `w` | Latin Small Letter W | `w` | Lowercase letter | | 120 | `78` | `170` | `01111000` | `x` | Latin Small Letter X | `x` | Lowercase letter | | 121 | `79` | `171` | `01111001` | `y` | Latin Small Letter Y | `y` | Lowercase letter | | 122 | `7A` | `172` | `01111010` | `z` | Latin Small Letter Z | `z` | Lowercase letter | | 123 | `7B` | `173` | `01111011` | `{` | Left Curly Bracket | `{` | Punctuation | | 124 | `7C` | `174` | `01111100` | `\|` | Vertical Line | `|` | Punctuation | | 125 | `7D` | `175` | `01111101` | `}` | Right Curly Bracket | `}` | Punctuation | | 126 | `7E` | `176` | `01111110` | `~` | Tilde | `~` | Punctuation | | 127 | `7F` | `177` | `01111111` | `DEL` | Delete | `` | Control | ## Control characters explained Thirty-three of the 128 code points print nothing. They were commands to a teleprinter or a communications link, and most are dead, but the survivors are load-bearing: you cannot write a network protocol, a terminal program or a file parser without meeting several of them. **What each one was designed to do, and where it survives** | Dec | Hex | Abbr | Name | Keystroke | Escape | What it was for | | ---: | ---: | --- | --- | --- | --- | --- | | 0 | `00` | `NUL` | Null | Ctrl+@ | `\0` | The all-zero byte. C uses it to mark the end of a string, which is why C strings cannot contain it. On paper tape it was blank tape, so it doubled as harmless padding. | | 1 | `01` | `SOH` | Start of Heading | Ctrl+A | - | Marked the start of a message header in old link protocols. Today it survives mostly as a field separator inside binary formats, and as the Ctrl+A keystroke (start of line in readline and tmux's prefix). | | 2 | `02` | `STX` | Start of Text | Ctrl+B | - | Ended the header and began the message body. Still used as a frame marker in serial and point-of-sale protocols. | | 3 | `03` | `ETX` | End of Text | Ctrl+C | - | Ended the message body. Far better known as Ctrl+C: terminals translate that keystroke into SIGINT, which is a terminal convention rather than anything ASCII mandates. | | 4 | `04` | `EOT` | End of Transmission | Ctrl+D | - | Ended the whole transmission. In a Unix terminal Ctrl+D sends no character at all: it tells the line discipline to flush the input buffer, which a reader sees as end of file. | | 5 | `05` | `ENQ` | Enquiry | Ctrl+E | - | Asked the far end to identify itself or confirm it was still alive. The ancestor of a keepalive ping. | | 6 | `06` | `ACK` | Acknowledge | Ctrl+F | - | Positive acknowledgement: the message arrived intact. Paired with NAK in stop-and-wait protocols such as XMODEM. | | 7 | `07` | `BEL` | Bell | Ctrl+G | `\a` | Rang the physical bell on a teletype. Terminals still beep or flash on it, and xterm-style title sequences are terminated by it. | | 8 | `08` | `BS` | Backspace | Ctrl+H | `\b` | Moved the print head back one position without erasing, so you could overstrike to make bold or accented characters. Note that the Backspace key usually sends DEL (127), not this. | | 9 | `09` | `HT` | Horizontal Tab | Ctrl+I | `\t` | Advance to the next tab stop. The stop positions are a property of the display, not the data, which is the root of every tabs-versus-spaces alignment argument. | | 10 | `0A` | `LF` | Line Feed | Ctrl+J | `\n` | Moved the paper up one line. Unix, Linux and macOS use it alone as the line terminator, and it is what C's \n means on those platforms. | | 11 | `0B` | `VT` | Vertical Tab | Ctrl+K | `\v` | Advance to the next vertical tab stop. Almost never used now, though it still counts as whitespace in most languages and as a line break in some Unicode algorithms. | | 12 | `0C` | `FF` | Form Feed | Ctrl+L | `\f` | Ejected the page on a printer. Some source files use it as a section separator, and Ctrl+L redraws the screen in many terminal programs. | | 13 | `0D` | `CR` | Carriage Return | Ctrl+M | `\r` | Returned the print head to column one without advancing the line. Alone it is the classic-Mac line ending; followed by LF it is the Windows, HTTP, SMTP and CSV line ending. | | 14 | `0E` | `SO` | Shift Out | Ctrl+N | - | Switched to an alternate character set, an early escape hatch for going beyond 128 characters. Terminals still use it to select the line-drawing set. | | 15 | `0F` | `SI` | Shift In | Ctrl+O | - | Switched back to the standard character set after SO. | | 16 | `10` | `DLE` | Data Link Escape | Ctrl+P | - | Made the following characters mean something to the link layer rather than the application. The idea behind byte stuffing, which reappears in PPP and SLIP. | | 17 | `11` | `DC1` | Device Control 1 | Ctrl+Q | - | Device control, in practice XON: resume transmission. Ctrl+Q unfreezes a terminal frozen by Ctrl+S. | | 18 | `12` | `DC2` | Device Control 2 | Ctrl+R | - | Device control, historically used to turn an auxiliary device such as a tape punch on. | | 19 | `13` | `DC3` | Device Control 3 | Ctrl+S | - | Device control, in practice XOFF: pause transmission. This is why Ctrl+S appears to hang a terminal, and it is a common surprise when it collides with an editor's save shortcut. | | 20 | `14` | `DC4` | Device Control 4 | Ctrl+T | - | Device control, historically used to turn an auxiliary device off. | | 21 | `15` | `NAK` | Negative Acknowledge | Ctrl+U | - | Negative acknowledgement: the message was damaged, send it again. The counterpart to ACK. | | 22 | `16` | `SYN` | Synchronous Idle | Ctrl+V | - | Filler sent on an idle synchronous line so that receiver and transmitter stayed in step. Ctrl+V is now widely repurposed as the literal-next-character key in terminals. | | 23 | `17` | `ETB` | End of Transmission Block | Ctrl+W | - | Ended one block of a message that had been split for transmission, without ending the message itself. | | 24 | `18` | `CAN` | Cancel | Ctrl+X | - | Told the receiver to discard the data that came before it. XMODEM still uses it to abort a transfer. | | 25 | `19` | `EM` | End of Medium | Ctrl+Y | - | Marked the physical end of the tape, card or other medium, which is not necessarily the end of the data. | | 26 | `1A` | `SUB` | Substitute | Ctrl+Z | - | Stood in for a character that could not be represented. DOS adopted it as the end-of-file marker in text files, and Unix shells use Ctrl+Z to suspend a job. | | 27 | `1B` | `ESC` | Escape | Ctrl+[ | `\e` | Introduces an escape sequence, giving the following characters a special meaning. Every ANSI terminal colour, cursor move and key code starts here. Note \e is a GNU extension, not standard C. | | 28 | `1C` | `FS` | File Separator | Ctrl+\ | - | The coarsest of the four data separators: divides files within a stream. | | 29 | `1D` | `GS` | Group Separator | Ctrl+] | - | Divides groups of records. Used in GS1 barcode data and in some EDI formats. | | 30 | `1E` | `RS` | Record Separator | Ctrl+^ | - | Divides records. ASCII-delimited text uses it as the row terminator instead of a newline, so records can contain newlines safely. | | 31 | `1F` | `US` | Unit Separator | Ctrl+_ | - | The finest separator: divides fields within a record. RS and US together give you a CSV that never needs quoting or escaping. | | 127 | `7F` | `DEL` | Delete | Ctrl+? | - | All seven bits set. On paper tape you deleted a character by punching every hole, so the reader skipped it. It sits at the end of the table rather than with the other controls for exactly that reason, and it is what most Backspace keys actually send. | ### Line endings, the one that actually bites CR (13) and LF (10) are two separate characters because a teleprinter needed two separate motions: return the carriage to the left margin, and advance the paper by one line. Operating systems then disagreed about which to keep. | Convention | Bytes | Written | Used by | | --- | --- | --- | --- | | LF | `0A` | `\n` | Unix, Linux, macOS since OS X, most programming languages | | CRLF | `0D 0A` | `\r\n` | Windows, HTTP, SMTP, FTP, CSV per RFC 4180, most internet protocols | | CR | `0D` | `\r` | Classic Mac OS up to version 9, now effectively extinct | Practical consequences: - A file written on Windows and read on Linux has a trailing `\r` on every line. It is invisible in most editors and it breaks string comparisons, so `if line == "yes"` fails on `"yes\r"`. Strip with `line.rstrip("\r\n")` in Python or `TrimRight` equivalents elsewhere. - Git normalises line endings if you ask it to. `* text=eol=lf` in `.gitattributes` is the usual fix, and it stops a diff showing every line of a file as changed. - Opening a file in text mode in C or Python on Windows silently translates CRLF to `\n` on read and back on write. Opening in binary mode (`"rb"`) does not. Mixing the two is a classic bug. - HTTP headers are terminated by CRLF, and the header block ends with a bare CRLF CRLF. If you are writing a socket server by hand, sending `\n` alone will work with lenient clients and fail with strict ones. ### The four separators nobody uses Codes 28 to 31 are FS, GS, RS and US: a four-level hierarchy of delimiters, built into ASCII from the start, and almost entirely ignored. ```text US (31) separates fields inside a record RS (30) separates records inside a group GS (29) separates groups inside a file FS (28) separates files inside a stream ``` The point is that these characters never appear in ordinary text, so a format built on them needs no quoting, no escaping and no rules about commas inside values. Every CSV parsing bug in history exists because the world picked a comma, which appears in real data, over US, which does not. They are still used in GS1 barcodes and some EDI and point-of-sale formats, and they are a reasonable choice for a quick internal data dump. ### Characters that are whitespace Six ASCII code points count as whitespace for `isspace` in C and for `\s` in most regular expression flavours: | Code | Char | Name | In `\s` | In `isspace` | | ---: | --- | --- | --- | --- | | 9 | `\t` | Horizontal tab | yes | yes | | 10 | `\n` | Line feed | yes | yes | | 11 | `\v` | Vertical tab | yes | yes | | 12 | `\f` | Form feed | yes | yes | | 13 | `\r` | Carriage return | yes | yes | | 32 | space | Space | yes | yes | Note what is not in that list: NUL is not whitespace, and neither is the no-break space at 160, which is not ASCII at all but turns up constantly in text copied from web pages and word processors. It looks exactly like a space and fails every equality test against one. ## Printable characters worth knowing **Printable characters worth knowing the number of** | Dec | Char | Name | Why it matters | | ---: | :---: | --- | --- | | 32 | `SP` (space) | Space | Code point 32 is the only printable character that is also whitespace. Its position immediately before the punctuation block means it sorts before every visible character. | | 34 | `"` | Quotation Mark | Must be escaped inside a double-quoted string in most languages, and inside JSON always. | | 38 | `&` | Ampersand | Must be escaped as &amp; in HTML and XML, including inside URLs written in HTML. | | 39 | `'` | Apostrophe | Different from the typographic apostrophe U+2019, which is what a word processor inserts. That mismatch is a common source of broken code pasted from a document. | | 45 | `-` | Hyphen-Minus | Also called hyphen-minus because ASCII has one character doing both jobs. Unicode separates them. | | 47 | `/` | Solidus | The path separator everywhere except Windows, and the only character besides NUL that a Unix filename may not contain. | | 48 | `0` | Digit Zero | The digits 48 to 57 are contiguous and their low four bits are the digit's value, so c - '0' converts a digit character to its number. | | 60 | `<` | Less-Than Sign | Must be escaped as &lt; in HTML. Unescaped user input containing it is the classic XSS vector. | | 64 | `@` | Commercial At | Chosen for email addresses by Ray Tomlinson in 1971 because it could not appear in a user name. | | 65 | `A` | Latin Capital Letter A | A is 65 and a is 97. The gap is exactly 32, one bit, which is the whole trick behind ASCII case conversion. | | 92 | `\` | Reverse Solidus | The escape character in almost every string literal, which is why Windows paths need doubling in source code. | | 94 | `^` | Circumflex Accent | Written as ^ in caret notation for control characters, so Ctrl+C is written ^C. | | 96 | `` ` `` | Grave Accent | Starts a template literal in JavaScript, a code span in Markdown and command substitution in older shell scripts. | | 97 | `a` | Latin Small Letter A | Lowercase letters run 97 to 122. Because they come after the uppercase letters, a naive byte sort puts Zebra before apple. | ## Converting between representations > **Interactive:** the web version has a text-and-codes converter here, which encodes > text to decimal, hex, octal, binary, HTML entities, C escapes or UTF-8 bytes, and > decodes any of those back to text. ### Doing it by hand Hex is the natural way to write ASCII because one hex digit is exactly four bits, so a byte is always two digits and the split lines up with the structure of the table. Octal is a leftover from machines with 12, 18 and 36 bit words, and it survives in C escapes and in Unix file permissions. ```text binary 0100 0001 hex 4 1 = 0x41 decimal 64 + 1 = 65 octal 001 000 001 = 0101 (group in threes from the right) ``` To go from decimal to binary quickly, subtract the powers of two from the left: ```text 75 - 64 = 11 so bit 6 is set (0100 0000) 11 - 8 = 3 so bit 3 is set (0000 1000) 3 - 2 = 1 so bit 1 is set (0000 0010) 1 - 1 = 0 so bit 0 is set (0000 0001) total 0100 1011 = 'K' ``` ### Doing it in code | Task | C | Python | Java | JavaScript | | --- | --- | --- | --- | --- | | Character to code | `(int) c` | `ord(c)` | `(int) c` | `s.charCodeAt(0)` | | Code to character | `(char) n` | `chr(n)` | `(char) n` | `String.fromCharCode(n)` | | To hex | `printf("%02X", c)` | `format(n, "02X")` | `String.format("%02X", n)` | `n.toString(16)` | | To binary | manual shift loop | `format(n, "08b")` | `Integer.toBinaryString(n)` | `n.toString(2)` | | Parse hex | `strtol(s, 0, 16)` | `int(s, 16)` | `Integer.parseInt(s, 16)` | `parseInt(s, 16)` | | Whole string to bytes | `(unsigned char *) s` | `s.encode("ascii")` | `s.getBytes(US_ASCII)` | `new TextEncoder().encode(s)` | | Is it ASCII | `c >= 0 && c < 128` | `s.isascii()` | `c < 128` | `/^[\x00-\x7F]*$/.test(s)` | Useful command line one-liners: ```bash # Show the bytes of a file, with printable characters alongside xxd file.txt | head # Same idea, named characters, good for spotting stray control bytes od -c file.txt | head # Look up a single character python3 -c "print(ord('A'))" # Print the whole printable range python3 -c "print(''.join(chr(i) for i in range(32,127)))" # The manual page that ships with most Unix systems man 7 ascii # Find non-ASCII bytes in a file grep -nP '[^\x00-\x7F]' file.txt ``` ## Beyond 7 bits: the extended code pages Once bytes were reliably 8 bits, the parity bit became free real estate, and everyone filled codes 128 to 255 differently. There is no such thing as "extended ASCII" as a single standard. If a file contains a byte above 127, you cannot know what character it means without being told the encoding. The three sets below are the ones you are most likely to meet. All three agree exactly with ASCII for bytes 0 to 127, which is the only reason mixed-encoding text is ever partially readable. ### ISO 8859-1, also called Latin-1 The ISO standard for Western European languages, and for a long time the default assumption for HTTP and for many databases. Bytes 160 to 255 are accented letters and common symbols. Bytes 128 to 159 are the C1 control range and are not printable characters at all. Latin-1 has one property that makes it special: its 256 characters map one to one onto the first 256 Unicode code points. Decoding arbitrary bytes as Latin-1 therefore never fails, which makes it a useful last resort for reading a file of unknown encoding without an exception, and a dangerous default because it silently produces nonsense rather than an error. **ISO 8859-1 (Latin-1), bytes 128-255** | Dec | Hex | Binary | Char | Unicode | Name | UTF-8 bytes | | ---: | ---: | --- | :---: | --- | --- | --- | | 128 | `80` | `10000000` | - | `U+0080` | PAD (C1 control) | `C2 80` | | 129 | `81` | `10000001` | - | `U+0081` | HOP (C1 control) | `C2 81` | | 130 | `82` | `10000010` | - | `U+0082` | BPH (C1 control) | `C2 82` | | 131 | `83` | `10000011` | - | `U+0083` | NBH (C1 control) | `C2 83` | | 132 | `84` | `10000100` | - | `U+0084` | IND (C1 control) | `C2 84` | | 133 | `85` | `10000101` | - | `U+0085` | NEL (C1 control) | `C2 85` | | 134 | `86` | `10000110` | - | `U+0086` | SSA (C1 control) | `C2 86` | | 135 | `87` | `10000111` | - | `U+0087` | ESA (C1 control) | `C2 87` | | 136 | `88` | `10001000` | - | `U+0088` | HTS (C1 control) | `C2 88` | | 137 | `89` | `10001001` | - | `U+0089` | HTJ (C1 control) | `C2 89` | | 138 | `8A` | `10001010` | - | `U+008A` | VTS (C1 control) | `C2 8A` | | 139 | `8B` | `10001011` | - | `U+008B` | PLD (C1 control) | `C2 8B` | | 140 | `8C` | `10001100` | - | `U+008C` | PLU (C1 control) | `C2 8C` | | 141 | `8D` | `10001101` | - | `U+008D` | RI (C1 control) | `C2 8D` | | 142 | `8E` | `10001110` | - | `U+008E` | SS2 (C1 control) | `C2 8E` | | 143 | `8F` | `10001111` | - | `U+008F` | SS3 (C1 control) | `C2 8F` | | 144 | `90` | `10010000` | - | `U+0090` | DCS (C1 control) | `C2 90` | | 145 | `91` | `10010001` | - | `U+0091` | PU1 (C1 control) | `C2 91` | | 146 | `92` | `10010010` | - | `U+0092` | PU2 (C1 control) | `C2 92` | | 147 | `93` | `10010011` | - | `U+0093` | STS (C1 control) | `C2 93` | | 148 | `94` | `10010100` | - | `U+0094` | CCH (C1 control) | `C2 94` | | 149 | `95` | `10010101` | - | `U+0095` | MW (C1 control) | `C2 95` | | 150 | `96` | `10010110` | - | `U+0096` | SPA (C1 control) | `C2 96` | | 151 | `97` | `10010111` | - | `U+0097` | EPA (C1 control) | `C2 97` | | 152 | `98` | `10011000` | - | `U+0098` | SOS (C1 control) | `C2 98` | | 153 | `99` | `10011001` | - | `U+0099` | SGC (C1 control) | `C2 99` | | 154 | `9A` | `10011010` | - | `U+009A` | SCI (C1 control) | `C2 9A` | | 155 | `9B` | `10011011` | - | `U+009B` | CSI (C1 control) | `C2 9B` | | 156 | `9C` | `10011100` | - | `U+009C` | ST (C1 control) | `C2 9C` | | 157 | `9D` | `10011101` | - | `U+009D` | OSC (C1 control) | `C2 9D` | | 158 | `9E` | `10011110` | - | `U+009E` | PM (C1 control) | `C2 9E` | | 159 | `9F` | `10011111` | - | `U+009F` | APC (C1 control) | `C2 9F` | | 160 | `A0` | `10100000` | ` ` | `U+00A0` | No-Break Space | `C2 A0` | | 161 | `A1` | `10100001` | `¡` | `U+00A1` | Inverted Exclamation Mark | `C2 A1` | | 162 | `A2` | `10100010` | `¢` | `U+00A2` | Cent Sign | `C2 A2` | | 163 | `A3` | `10100011` | `£` | `U+00A3` | Pound Sign | `C2 A3` | | 164 | `A4` | `10100100` | `¤` | `U+00A4` | Currency Sign | `C2 A4` | | 165 | `A5` | `10100101` | `¥` | `U+00A5` | Yen Sign | `C2 A5` | | 166 | `A6` | `10100110` | `¦` | `U+00A6` | Broken Bar | `C2 A6` | | 167 | `A7` | `10100111` | `§` | `U+00A7` | Section Sign | `C2 A7` | | 168 | `A8` | `10101000` | `¨` | `U+00A8` | Diaeresis | `C2 A8` | | 169 | `A9` | `10101001` | `©` | `U+00A9` | Copyright Sign | `C2 A9` | | 170 | `AA` | `10101010` | `ª` | `U+00AA` | Feminine Ordinal Indicator | `C2 AA` | | 171 | `AB` | `10101011` | `«` | `U+00AB` | Left-Pointing Double Angle Quotation Mark | `C2 AB` | | 172 | `AC` | `10101100` | `¬` | `U+00AC` | Not Sign | `C2 AC` | | 173 | `AD` | `10101101` | `­` | `U+00AD` | Soft Hyphen | `C2 AD` | | 174 | `AE` | `10101110` | `®` | `U+00AE` | Registered Sign | `C2 AE` | | 175 | `AF` | `10101111` | `¯` | `U+00AF` | Macron | `C2 AF` | | 176 | `B0` | `10110000` | `°` | `U+00B0` | Degree Sign | `C2 B0` | | 177 | `B1` | `10110001` | `±` | `U+00B1` | Plus-Minus Sign | `C2 B1` | | 178 | `B2` | `10110010` | `²` | `U+00B2` | Superscript Two | `C2 B2` | | 179 | `B3` | `10110011` | `³` | `U+00B3` | Superscript Three | `C2 B3` | | 180 | `B4` | `10110100` | `´` | `U+00B4` | Acute Accent | `C2 B4` | | 181 | `B5` | `10110101` | `µ` | `U+00B5` | Micro Sign | `C2 B5` | | 182 | `B6` | `10110110` | `¶` | `U+00B6` | Pilcrow Sign | `C2 B6` | | 183 | `B7` | `10110111` | `·` | `U+00B7` | Middle Dot | `C2 B7` | | 184 | `B8` | `10111000` | `¸` | `U+00B8` | Cedilla | `C2 B8` | | 185 | `B9` | `10111001` | `¹` | `U+00B9` | Superscript One | `C2 B9` | | 186 | `BA` | `10111010` | `º` | `U+00BA` | Masculine Ordinal Indicator | `C2 BA` | | 187 | `BB` | `10111011` | `»` | `U+00BB` | Right-Pointing Double Angle Quotation Mark | `C2 BB` | | 188 | `BC` | `10111100` | `¼` | `U+00BC` | Vulgar Fraction One Quarter | `C2 BC` | | 189 | `BD` | `10111101` | `½` | `U+00BD` | Vulgar Fraction One Half | `C2 BD` | | 190 | `BE` | `10111110` | `¾` | `U+00BE` | Vulgar Fraction Three Quarters | `C2 BE` | | 191 | `BF` | `10111111` | `¿` | `U+00BF` | Inverted Question Mark | `C2 BF` | | 192 | `C0` | `11000000` | `À` | `U+00C0` | Latin Capital Letter A With Grave | `C3 80` | | 193 | `C1` | `11000001` | `Á` | `U+00C1` | Latin Capital Letter A With Acute | `C3 81` | | 194 | `C2` | `11000010` | `Â` | `U+00C2` | Latin Capital Letter A With Circumflex | `C3 82` | | 195 | `C3` | `11000011` | `Ã` | `U+00C3` | Latin Capital Letter A With Tilde | `C3 83` | | 196 | `C4` | `11000100` | `Ä` | `U+00C4` | Latin Capital Letter A With Diaeresis | `C3 84` | | 197 | `C5` | `11000101` | `Å` | `U+00C5` | Latin Capital Letter A With Ring Above | `C3 85` | | 198 | `C6` | `11000110` | `Æ` | `U+00C6` | Latin Capital Letter AE | `C3 86` | | 199 | `C7` | `11000111` | `Ç` | `U+00C7` | Latin Capital Letter C With Cedilla | `C3 87` | | 200 | `C8` | `11001000` | `È` | `U+00C8` | Latin Capital Letter E With Grave | `C3 88` | | 201 | `C9` | `11001001` | `É` | `U+00C9` | Latin Capital Letter E With Acute | `C3 89` | | 202 | `CA` | `11001010` | `Ê` | `U+00CA` | Latin Capital Letter E With Circumflex | `C3 8A` | | 203 | `CB` | `11001011` | `Ë` | `U+00CB` | Latin Capital Letter E With Diaeresis | `C3 8B` | | 204 | `CC` | `11001100` | `Ì` | `U+00CC` | Latin Capital Letter I With Grave | `C3 8C` | | 205 | `CD` | `11001101` | `Í` | `U+00CD` | Latin Capital Letter I With Acute | `C3 8D` | | 206 | `CE` | `11001110` | `Î` | `U+00CE` | Latin Capital Letter I With Circumflex | `C3 8E` | | 207 | `CF` | `11001111` | `Ï` | `U+00CF` | Latin Capital Letter I With Diaeresis | `C3 8F` | | 208 | `D0` | `11010000` | `Ð` | `U+00D0` | Latin Capital Letter Eth | `C3 90` | | 209 | `D1` | `11010001` | `Ñ` | `U+00D1` | Latin Capital Letter N With Tilde | `C3 91` | | 210 | `D2` | `11010010` | `Ò` | `U+00D2` | Latin Capital Letter O With Grave | `C3 92` | | 211 | `D3` | `11010011` | `Ó` | `U+00D3` | Latin Capital Letter O With Acute | `C3 93` | | 212 | `D4` | `11010100` | `Ô` | `U+00D4` | Latin Capital Letter O With Circumflex | `C3 94` | | 213 | `D5` | `11010101` | `Õ` | `U+00D5` | Latin Capital Letter O With Tilde | `C3 95` | | 214 | `D6` | `11010110` | `Ö` | `U+00D6` | Latin Capital Letter O With Diaeresis | `C3 96` | | 215 | `D7` | `11010111` | `×` | `U+00D7` | Multiplication Sign | `C3 97` | | 216 | `D8` | `11011000` | `Ø` | `U+00D8` | Latin Capital Letter O With Stroke | `C3 98` | | 217 | `D9` | `11011001` | `Ù` | `U+00D9` | Latin Capital Letter U With Grave | `C3 99` | | 218 | `DA` | `11011010` | `Ú` | `U+00DA` | Latin Capital Letter U With Acute | `C3 9A` | | 219 | `DB` | `11011011` | `Û` | `U+00DB` | Latin Capital Letter U With Circumflex | `C3 9B` | | 220 | `DC` | `11011100` | `Ü` | `U+00DC` | Latin Capital Letter U With Diaeresis | `C3 9C` | | 221 | `DD` | `11011101` | `Ý` | `U+00DD` | Latin Capital Letter Y With Acute | `C3 9D` | | 222 | `DE` | `11011110` | `Þ` | `U+00DE` | Latin Capital Letter Thorn | `C3 9E` | | 223 | `DF` | `11011111` | `ß` | `U+00DF` | Latin Small Letter Sharp S | `C3 9F` | | 224 | `E0` | `11100000` | `à` | `U+00E0` | Latin Small Letter A With Grave | `C3 A0` | | 225 | `E1` | `11100001` | `á` | `U+00E1` | Latin Small Letter A With Acute | `C3 A1` | | 226 | `E2` | `11100010` | `â` | `U+00E2` | Latin Small Letter A With Circumflex | `C3 A2` | | 227 | `E3` | `11100011` | `ã` | `U+00E3` | Latin Small Letter A With Tilde | `C3 A3` | | 228 | `E4` | `11100100` | `ä` | `U+00E4` | Latin Small Letter A With Diaeresis | `C3 A4` | | 229 | `E5` | `11100101` | `å` | `U+00E5` | Latin Small Letter A With Ring Above | `C3 A5` | | 230 | `E6` | `11100110` | `æ` | `U+00E6` | Latin Small Letter AE | `C3 A6` | | 231 | `E7` | `11100111` | `ç` | `U+00E7` | Latin Small Letter C With Cedilla | `C3 A7` | | 232 | `E8` | `11101000` | `è` | `U+00E8` | Latin Small Letter E With Grave | `C3 A8` | | 233 | `E9` | `11101001` | `é` | `U+00E9` | Latin Small Letter E With Acute | `C3 A9` | | 234 | `EA` | `11101010` | `ê` | `U+00EA` | Latin Small Letter E With Circumflex | `C3 AA` | | 235 | `EB` | `11101011` | `ë` | `U+00EB` | Latin Small Letter E With Diaeresis | `C3 AB` | | 236 | `EC` | `11101100` | `ì` | `U+00EC` | Latin Small Letter I With Grave | `C3 AC` | | 237 | `ED` | `11101101` | `í` | `U+00ED` | Latin Small Letter I With Acute | `C3 AD` | | 238 | `EE` | `11101110` | `î` | `U+00EE` | Latin Small Letter I With Circumflex | `C3 AE` | | 239 | `EF` | `11101111` | `ï` | `U+00EF` | Latin Small Letter I With Diaeresis | `C3 AF` | | 240 | `F0` | `11110000` | `ð` | `U+00F0` | Latin Small Letter Eth | `C3 B0` | | 241 | `F1` | `11110001` | `ñ` | `U+00F1` | Latin Small Letter N With Tilde | `C3 B1` | | 242 | `F2` | `11110010` | `ò` | `U+00F2` | Latin Small Letter O With Grave | `C3 B2` | | 243 | `F3` | `11110011` | `ó` | `U+00F3` | Latin Small Letter O With Acute | `C3 B3` | | 244 | `F4` | `11110100` | `ô` | `U+00F4` | Latin Small Letter O With Circumflex | `C3 B4` | | 245 | `F5` | `11110101` | `õ` | `U+00F5` | Latin Small Letter O With Tilde | `C3 B5` | | 246 | `F6` | `11110110` | `ö` | `U+00F6` | Latin Small Letter O With Diaeresis | `C3 B6` | | 247 | `F7` | `11110111` | `÷` | `U+00F7` | Division Sign | `C3 B7` | | 248 | `F8` | `11111000` | `ø` | `U+00F8` | Latin Small Letter O With Stroke | `C3 B8` | | 249 | `F9` | `11111001` | `ù` | `U+00F9` | Latin Small Letter U With Grave | `C3 B9` | | 250 | `FA` | `11111010` | `ú` | `U+00FA` | Latin Small Letter U With Acute | `C3 BA` | | 251 | `FB` | `11111011` | `û` | `U+00FB` | Latin Small Letter U With Circumflex | `C3 BB` | | 252 | `FC` | `11111100` | `ü` | `U+00FC` | Latin Small Letter U With Diaeresis | `C3 BC` | | 253 | `FD` | `11111101` | `ý` | `U+00FD` | Latin Small Letter Y With Acute | `C3 BD` | | 254 | `FE` | `11111110` | `þ` | `U+00FE` | Latin Small Letter Thorn | `C3 BE` | | 255 | `FF` | `11111111` | `ÿ` | `U+00FF` | Latin Small Letter Y With Diaeresis | `C3 BF` | ### Windows-1252 Microsoft's near-identical variant, and the real encoding behind a great deal of text that claims to be Latin-1. It matches ISO 8859-1 everywhere except 128 to 159, where instead of C1 controls it puts typographic characters: curly quotes, the en dash and em dash, the bullet, the ellipsis and the euro sign. This single difference causes most of the mojibake on the web. A document is labelled `ISO-8859-1`, actually contains Windows-1252, and its curly quotes decode as invisible control characters or as replacement characters. The HTML5 specification gave up and requires browsers to decode anything labelled `ISO-8859-1` as `windows-1252` instead. **Windows-1252, bytes 128-255** | Dec | Hex | Binary | Char | Unicode | Name | UTF-8 bytes | | ---: | ---: | --- | :---: | --- | --- | --- | | 128 | `80` | `10000000` | `€` | `U+20AC` | Euro Sign | `E2 82 AC` | | 129 | `81` | `10000001` | - | - | Undefined | - | | 130 | `82` | `10000010` | `‚` | `U+201A` | Single Low-9 Quotation Mark | `E2 80 9A` | | 131 | `83` | `10000011` | `ƒ` | `U+0192` | Latin Small Letter F With Hook | `C6 92` | | 132 | `84` | `10000100` | `„` | `U+201E` | Double Low-9 Quotation Mark | `E2 80 9E` | | 133 | `85` | `10000101` | `…` | `U+2026` | Horizontal Ellipsis | `E2 80 A6` | | 134 | `86` | `10000110` | `†` | `U+2020` | Dagger | `E2 80 A0` | | 135 | `87` | `10000111` | `‡` | `U+2021` | Double Dagger | `E2 80 A1` | | 136 | `88` | `10001000` | `ˆ` | `U+02C6` | Modifier Letter Circumflex Accent | `CB 86` | | 137 | `89` | `10001001` | `‰` | `U+2030` | Per Mille Sign | `E2 80 B0` | | 138 | `8A` | `10001010` | `Š` | `U+0160` | Latin Capital Letter S With Caron | `C5 A0` | | 139 | `8B` | `10001011` | `‹` | `U+2039` | Single Left-Pointing Angle Quotation Mark | `E2 80 B9` | | 140 | `8C` | `10001100` | `Œ` | `U+0152` | Latin Capital Ligature OE | `C5 92` | | 141 | `8D` | `10001101` | - | - | Undefined | - | | 142 | `8E` | `10001110` | `Ž` | `U+017D` | Latin Capital Letter Z With Caron | `C5 BD` | | 143 | `8F` | `10001111` | - | - | Undefined | - | | 144 | `90` | `10010000` | - | - | Undefined | - | | 145 | `91` | `10010001` | `‘` | `U+2018` | Left Single Quotation Mark | `E2 80 98` | | 146 | `92` | `10010010` | `’` | `U+2019` | Right Single Quotation Mark | `E2 80 99` | | 147 | `93` | `10010011` | `“` | `U+201C` | Left Double Quotation Mark | `E2 80 9C` | | 148 | `94` | `10010100` | `”` | `U+201D` | Right Double Quotation Mark | `E2 80 9D` | | 149 | `95` | `10010101` | `•` | `U+2022` | Bullet | `E2 80 A2` | | 150 | `96` | `10010110` | `–` | `U+2013` | En Dash | `E2 80 93` | | 151 | `97` | `10010111` | `—` | `U+2014` | Em Dash | `E2 80 94` | | 152 | `98` | `10011000` | `˜` | `U+02DC` | Small Tilde | `CB 9C` | | 153 | `99` | `10011001` | `™` | `U+2122` | Trade Mark Sign | `E2 84 A2` | | 154 | `9A` | `10011010` | `š` | `U+0161` | Latin Small Letter S With Caron | `C5 A1` | | 155 | `9B` | `10011011` | `›` | `U+203A` | Single Right-Pointing Angle Quotation Mark | `E2 80 BA` | | 156 | `9C` | `10011100` | `œ` | `U+0153` | Latin Small Ligature OE | `C5 93` | | 157 | `9D` | `10011101` | - | - | Undefined | - | | 158 | `9E` | `10011110` | `ž` | `U+017E` | Latin Small Letter Z With Caron | `C5 BE` | | 159 | `9F` | `10011111` | `Ÿ` | `U+0178` | Latin Capital Letter Y With Diaeresis | `C5 B8` | | 160 | `A0` | `10100000` | ` ` | `U+00A0` | No-Break Space | `C2 A0` | | 161 | `A1` | `10100001` | `¡` | `U+00A1` | Inverted Exclamation Mark | `C2 A1` | | 162 | `A2` | `10100010` | `¢` | `U+00A2` | Cent Sign | `C2 A2` | | 163 | `A3` | `10100011` | `£` | `U+00A3` | Pound Sign | `C2 A3` | | 164 | `A4` | `10100100` | `¤` | `U+00A4` | Currency Sign | `C2 A4` | | 165 | `A5` | `10100101` | `¥` | `U+00A5` | Yen Sign | `C2 A5` | | 166 | `A6` | `10100110` | `¦` | `U+00A6` | Broken Bar | `C2 A6` | | 167 | `A7` | `10100111` | `§` | `U+00A7` | Section Sign | `C2 A7` | | 168 | `A8` | `10101000` | `¨` | `U+00A8` | Diaeresis | `C2 A8` | | 169 | `A9` | `10101001` | `©` | `U+00A9` | Copyright Sign | `C2 A9` | | 170 | `AA` | `10101010` | `ª` | `U+00AA` | Feminine Ordinal Indicator | `C2 AA` | | 171 | `AB` | `10101011` | `«` | `U+00AB` | Left-Pointing Double Angle Quotation Mark | `C2 AB` | | 172 | `AC` | `10101100` | `¬` | `U+00AC` | Not Sign | `C2 AC` | | 173 | `AD` | `10101101` | `­` | `U+00AD` | Soft Hyphen | `C2 AD` | | 174 | `AE` | `10101110` | `®` | `U+00AE` | Registered Sign | `C2 AE` | | 175 | `AF` | `10101111` | `¯` | `U+00AF` | Macron | `C2 AF` | | 176 | `B0` | `10110000` | `°` | `U+00B0` | Degree Sign | `C2 B0` | | 177 | `B1` | `10110001` | `±` | `U+00B1` | Plus-Minus Sign | `C2 B1` | | 178 | `B2` | `10110010` | `²` | `U+00B2` | Superscript Two | `C2 B2` | | 179 | `B3` | `10110011` | `³` | `U+00B3` | Superscript Three | `C2 B3` | | 180 | `B4` | `10110100` | `´` | `U+00B4` | Acute Accent | `C2 B4` | | 181 | `B5` | `10110101` | `µ` | `U+00B5` | Micro Sign | `C2 B5` | | 182 | `B6` | `10110110` | `¶` | `U+00B6` | Pilcrow Sign | `C2 B6` | | 183 | `B7` | `10110111` | `·` | `U+00B7` | Middle Dot | `C2 B7` | | 184 | `B8` | `10111000` | `¸` | `U+00B8` | Cedilla | `C2 B8` | | 185 | `B9` | `10111001` | `¹` | `U+00B9` | Superscript One | `C2 B9` | | 186 | `BA` | `10111010` | `º` | `U+00BA` | Masculine Ordinal Indicator | `C2 BA` | | 187 | `BB` | `10111011` | `»` | `U+00BB` | Right-Pointing Double Angle Quotation Mark | `C2 BB` | | 188 | `BC` | `10111100` | `¼` | `U+00BC` | Vulgar Fraction One Quarter | `C2 BC` | | 189 | `BD` | `10111101` | `½` | `U+00BD` | Vulgar Fraction One Half | `C2 BD` | | 190 | `BE` | `10111110` | `¾` | `U+00BE` | Vulgar Fraction Three Quarters | `C2 BE` | | 191 | `BF` | `10111111` | `¿` | `U+00BF` | Inverted Question Mark | `C2 BF` | | 192 | `C0` | `11000000` | `À` | `U+00C0` | Latin Capital Letter A With Grave | `C3 80` | | 193 | `C1` | `11000001` | `Á` | `U+00C1` | Latin Capital Letter A With Acute | `C3 81` | | 194 | `C2` | `11000010` | `Â` | `U+00C2` | Latin Capital Letter A With Circumflex | `C3 82` | | 195 | `C3` | `11000011` | `Ã` | `U+00C3` | Latin Capital Letter A With Tilde | `C3 83` | | 196 | `C4` | `11000100` | `Ä` | `U+00C4` | Latin Capital Letter A With Diaeresis | `C3 84` | | 197 | `C5` | `11000101` | `Å` | `U+00C5` | Latin Capital Letter A With Ring Above | `C3 85` | | 198 | `C6` | `11000110` | `Æ` | `U+00C6` | Latin Capital Letter AE | `C3 86` | | 199 | `C7` | `11000111` | `Ç` | `U+00C7` | Latin Capital Letter C With Cedilla | `C3 87` | | 200 | `C8` | `11001000` | `È` | `U+00C8` | Latin Capital Letter E With Grave | `C3 88` | | 201 | `C9` | `11001001` | `É` | `U+00C9` | Latin Capital Letter E With Acute | `C3 89` | | 202 | `CA` | `11001010` | `Ê` | `U+00CA` | Latin Capital Letter E With Circumflex | `C3 8A` | | 203 | `CB` | `11001011` | `Ë` | `U+00CB` | Latin Capital Letter E With Diaeresis | `C3 8B` | | 204 | `CC` | `11001100` | `Ì` | `U+00CC` | Latin Capital Letter I With Grave | `C3 8C` | | 205 | `CD` | `11001101` | `Í` | `U+00CD` | Latin Capital Letter I With Acute | `C3 8D` | | 206 | `CE` | `11001110` | `Î` | `U+00CE` | Latin Capital Letter I With Circumflex | `C3 8E` | | 207 | `CF` | `11001111` | `Ï` | `U+00CF` | Latin Capital Letter I With Diaeresis | `C3 8F` | | 208 | `D0` | `11010000` | `Ð` | `U+00D0` | Latin Capital Letter Eth | `C3 90` | | 209 | `D1` | `11010001` | `Ñ` | `U+00D1` | Latin Capital Letter N With Tilde | `C3 91` | | 210 | `D2` | `11010010` | `Ò` | `U+00D2` | Latin Capital Letter O With Grave | `C3 92` | | 211 | `D3` | `11010011` | `Ó` | `U+00D3` | Latin Capital Letter O With Acute | `C3 93` | | 212 | `D4` | `11010100` | `Ô` | `U+00D4` | Latin Capital Letter O With Circumflex | `C3 94` | | 213 | `D5` | `11010101` | `Õ` | `U+00D5` | Latin Capital Letter O With Tilde | `C3 95` | | 214 | `D6` | `11010110` | `Ö` | `U+00D6` | Latin Capital Letter O With Diaeresis | `C3 96` | | 215 | `D7` | `11010111` | `×` | `U+00D7` | Multiplication Sign | `C3 97` | | 216 | `D8` | `11011000` | `Ø` | `U+00D8` | Latin Capital Letter O With Stroke | `C3 98` | | 217 | `D9` | `11011001` | `Ù` | `U+00D9` | Latin Capital Letter U With Grave | `C3 99` | | 218 | `DA` | `11011010` | `Ú` | `U+00DA` | Latin Capital Letter U With Acute | `C3 9A` | | 219 | `DB` | `11011011` | `Û` | `U+00DB` | Latin Capital Letter U With Circumflex | `C3 9B` | | 220 | `DC` | `11011100` | `Ü` | `U+00DC` | Latin Capital Letter U With Diaeresis | `C3 9C` | | 221 | `DD` | `11011101` | `Ý` | `U+00DD` | Latin Capital Letter Y With Acute | `C3 9D` | | 222 | `DE` | `11011110` | `Þ` | `U+00DE` | Latin Capital Letter Thorn | `C3 9E` | | 223 | `DF` | `11011111` | `ß` | `U+00DF` | Latin Small Letter Sharp S | `C3 9F` | | 224 | `E0` | `11100000` | `à` | `U+00E0` | Latin Small Letter A With Grave | `C3 A0` | | 225 | `E1` | `11100001` | `á` | `U+00E1` | Latin Small Letter A With Acute | `C3 A1` | | 226 | `E2` | `11100010` | `â` | `U+00E2` | Latin Small Letter A With Circumflex | `C3 A2` | | 227 | `E3` | `11100011` | `ã` | `U+00E3` | Latin Small Letter A With Tilde | `C3 A3` | | 228 | `E4` | `11100100` | `ä` | `U+00E4` | Latin Small Letter A With Diaeresis | `C3 A4` | | 229 | `E5` | `11100101` | `å` | `U+00E5` | Latin Small Letter A With Ring Above | `C3 A5` | | 230 | `E6` | `11100110` | `æ` | `U+00E6` | Latin Small Letter AE | `C3 A6` | | 231 | `E7` | `11100111` | `ç` | `U+00E7` | Latin Small Letter C With Cedilla | `C3 A7` | | 232 | `E8` | `11101000` | `è` | `U+00E8` | Latin Small Letter E With Grave | `C3 A8` | | 233 | `E9` | `11101001` | `é` | `U+00E9` | Latin Small Letter E With Acute | `C3 A9` | | 234 | `EA` | `11101010` | `ê` | `U+00EA` | Latin Small Letter E With Circumflex | `C3 AA` | | 235 | `EB` | `11101011` | `ë` | `U+00EB` | Latin Small Letter E With Diaeresis | `C3 AB` | | 236 | `EC` | `11101100` | `ì` | `U+00EC` | Latin Small Letter I With Grave | `C3 AC` | | 237 | `ED` | `11101101` | `í` | `U+00ED` | Latin Small Letter I With Acute | `C3 AD` | | 238 | `EE` | `11101110` | `î` | `U+00EE` | Latin Small Letter I With Circumflex | `C3 AE` | | 239 | `EF` | `11101111` | `ï` | `U+00EF` | Latin Small Letter I With Diaeresis | `C3 AF` | | 240 | `F0` | `11110000` | `ð` | `U+00F0` | Latin Small Letter Eth | `C3 B0` | | 241 | `F1` | `11110001` | `ñ` | `U+00F1` | Latin Small Letter N With Tilde | `C3 B1` | | 242 | `F2` | `11110010` | `ò` | `U+00F2` | Latin Small Letter O With Grave | `C3 B2` | | 243 | `F3` | `11110011` | `ó` | `U+00F3` | Latin Small Letter O With Acute | `C3 B3` | | 244 | `F4` | `11110100` | `ô` | `U+00F4` | Latin Small Letter O With Circumflex | `C3 B4` | | 245 | `F5` | `11110101` | `õ` | `U+00F5` | Latin Small Letter O With Tilde | `C3 B5` | | 246 | `F6` | `11110110` | `ö` | `U+00F6` | Latin Small Letter O With Diaeresis | `C3 B6` | | 247 | `F7` | `11110111` | `÷` | `U+00F7` | Division Sign | `C3 B7` | | 248 | `F8` | `11111000` | `ø` | `U+00F8` | Latin Small Letter O With Stroke | `C3 B8` | | 249 | `F9` | `11111001` | `ù` | `U+00F9` | Latin Small Letter U With Grave | `C3 B9` | | 250 | `FA` | `11111010` | `ú` | `U+00FA` | Latin Small Letter U With Acute | `C3 BA` | | 251 | `FB` | `11111011` | `û` | `U+00FB` | Latin Small Letter U With Circumflex | `C3 BB` | | 252 | `FC` | `11111100` | `ü` | `U+00FC` | Latin Small Letter U With Diaeresis | `C3 BC` | | 253 | `FD` | `11111101` | `ý` | `U+00FD` | Latin Small Letter Y With Acute | `C3 BD` | | 254 | `FE` | `11111110` | `þ` | `U+00FE` | Latin Small Letter Thorn | `C3 BE` | | 255 | `FF` | `11111111` | `ÿ` | `U+00FF` | Latin Small Letter Y With Diaeresis | `C3 BF` | ### Code page 437 The character set burned into the ROM of the original IBM PC. It uses the upper 128 for accented letters, Greek letters, mathematical symbols and, most famously, the box-drawing and shading characters that every DOS-era text interface was built from. Anyone who has seen an old installer's blue screen with double-line borders has seen CP437. It is worth knowing for two reasons: it is the encoding of a great deal of historical material, including ANSI art and the text-mode games of the period, and its box-drawing characters were all adopted into Unicode, so you can still use them today. **Code page 437, the original IBM PC set, bytes 128-255** | Dec | Hex | Binary | Char | Unicode | Name | UTF-8 bytes | | ---: | ---: | --- | :---: | --- | --- | --- | | 128 | `80` | `10000000` | `Ç` | `U+00C7` | Latin Capital Letter C With Cedilla | `C3 87` | | 129 | `81` | `10000001` | `ü` | `U+00FC` | Latin Small Letter U With Diaeresis | `C3 BC` | | 130 | `82` | `10000010` | `é` | `U+00E9` | Latin Small Letter E With Acute | `C3 A9` | | 131 | `83` | `10000011` | `â` | `U+00E2` | Latin Small Letter A With Circumflex | `C3 A2` | | 132 | `84` | `10000100` | `ä` | `U+00E4` | Latin Small Letter A With Diaeresis | `C3 A4` | | 133 | `85` | `10000101` | `à` | `U+00E0` | Latin Small Letter A With Grave | `C3 A0` | | 134 | `86` | `10000110` | `å` | `U+00E5` | Latin Small Letter A With Ring Above | `C3 A5` | | 135 | `87` | `10000111` | `ç` | `U+00E7` | Latin Small Letter C With Cedilla | `C3 A7` | | 136 | `88` | `10001000` | `ê` | `U+00EA` | Latin Small Letter E With Circumflex | `C3 AA` | | 137 | `89` | `10001001` | `ë` | `U+00EB` | Latin Small Letter E With Diaeresis | `C3 AB` | | 138 | `8A` | `10001010` | `è` | `U+00E8` | Latin Small Letter E With Grave | `C3 A8` | | 139 | `8B` | `10001011` | `ï` | `U+00EF` | Latin Small Letter I With Diaeresis | `C3 AF` | | 140 | `8C` | `10001100` | `î` | `U+00EE` | Latin Small Letter I With Circumflex | `C3 AE` | | 141 | `8D` | `10001101` | `ì` | `U+00EC` | Latin Small Letter I With Grave | `C3 AC` | | 142 | `8E` | `10001110` | `Ä` | `U+00C4` | Latin Capital Letter A With Diaeresis | `C3 84` | | 143 | `8F` | `10001111` | `Å` | `U+00C5` | Latin Capital Letter A With Ring Above | `C3 85` | | 144 | `90` | `10010000` | `É` | `U+00C9` | Latin Capital Letter E With Acute | `C3 89` | | 145 | `91` | `10010001` | `æ` | `U+00E6` | Latin Small Letter AE | `C3 A6` | | 146 | `92` | `10010010` | `Æ` | `U+00C6` | Latin Capital Letter AE | `C3 86` | | 147 | `93` | `10010011` | `ô` | `U+00F4` | Latin Small Letter O With Circumflex | `C3 B4` | | 148 | `94` | `10010100` | `ö` | `U+00F6` | Latin Small Letter O With Diaeresis | `C3 B6` | | 149 | `95` | `10010101` | `ò` | `U+00F2` | Latin Small Letter O With Grave | `C3 B2` | | 150 | `96` | `10010110` | `û` | `U+00FB` | Latin Small Letter U With Circumflex | `C3 BB` | | 151 | `97` | `10010111` | `ù` | `U+00F9` | Latin Small Letter U With Grave | `C3 B9` | | 152 | `98` | `10011000` | `ÿ` | `U+00FF` | Latin Small Letter Y With Diaeresis | `C3 BF` | | 153 | `99` | `10011001` | `Ö` | `U+00D6` | Latin Capital Letter O With Diaeresis | `C3 96` | | 154 | `9A` | `10011010` | `Ü` | `U+00DC` | Latin Capital Letter U With Diaeresis | `C3 9C` | | 155 | `9B` | `10011011` | `¢` | `U+00A2` | Cent Sign | `C2 A2` | | 156 | `9C` | `10011100` | `£` | `U+00A3` | Pound Sign | `C2 A3` | | 157 | `9D` | `10011101` | `¥` | `U+00A5` | Yen Sign | `C2 A5` | | 158 | `9E` | `10011110` | `₧` | `U+20A7` | Peseta Sign | `E2 82 A7` | | 159 | `9F` | `10011111` | `ƒ` | `U+0192` | Latin Small Letter F With Hook | `C6 92` | | 160 | `A0` | `10100000` | `á` | `U+00E1` | Latin Small Letter A With Acute | `C3 A1` | | 161 | `A1` | `10100001` | `í` | `U+00ED` | Latin Small Letter I With Acute | `C3 AD` | | 162 | `A2` | `10100010` | `ó` | `U+00F3` | Latin Small Letter O With Acute | `C3 B3` | | 163 | `A3` | `10100011` | `ú` | `U+00FA` | Latin Small Letter U With Acute | `C3 BA` | | 164 | `A4` | `10100100` | `ñ` | `U+00F1` | Latin Small Letter N With Tilde | `C3 B1` | | 165 | `A5` | `10100101` | `Ñ` | `U+00D1` | Latin Capital Letter N With Tilde | `C3 91` | | 166 | `A6` | `10100110` | `ª` | `U+00AA` | Feminine Ordinal Indicator | `C2 AA` | | 167 | `A7` | `10100111` | `º` | `U+00BA` | Masculine Ordinal Indicator | `C2 BA` | | 168 | `A8` | `10101000` | `¿` | `U+00BF` | Inverted Question Mark | `C2 BF` | | 169 | `A9` | `10101001` | `⌐` | `U+2310` | Reversed Not Sign | `E2 8C 90` | | 170 | `AA` | `10101010` | `¬` | `U+00AC` | Not Sign | `C2 AC` | | 171 | `AB` | `10101011` | `½` | `U+00BD` | Vulgar Fraction One Half | `C2 BD` | | 172 | `AC` | `10101100` | `¼` | `U+00BC` | Vulgar Fraction One Quarter | `C2 BC` | | 173 | `AD` | `10101101` | `¡` | `U+00A1` | Inverted Exclamation Mark | `C2 A1` | | 174 | `AE` | `10101110` | `«` | `U+00AB` | Left-Pointing Double Angle Quotation Mark | `C2 AB` | | 175 | `AF` | `10101111` | `»` | `U+00BB` | Right-Pointing Double Angle Quotation Mark | `C2 BB` | | 176 | `B0` | `10110000` | `░` | `U+2591` | Light Shade | `E2 96 91` | | 177 | `B1` | `10110001` | `▒` | `U+2592` | Medium Shade | `E2 96 92` | | 178 | `B2` | `10110010` | `▓` | `U+2593` | Dark Shade | `E2 96 93` | | 179 | `B3` | `10110011` | `│` | `U+2502` | Box Drawings Light Vertical | `E2 94 82` | | 180 | `B4` | `10110100` | `┤` | `U+2524` | Box Drawings Light Vertical And Left | `E2 94 A4` | | 181 | `B5` | `10110101` | `╡` | `U+2561` | Box Drawings Vertical Single And Left Double | `E2 95 A1` | | 182 | `B6` | `10110110` | `╢` | `U+2562` | Box Drawings Vertical Double And Left Single | `E2 95 A2` | | 183 | `B7` | `10110111` | `╖` | `U+2556` | Box Drawings Down Double And Left Single | `E2 95 96` | | 184 | `B8` | `10111000` | `╕` | `U+2555` | Box Drawings Down Single And Left Double | `E2 95 95` | | 185 | `B9` | `10111001` | `╣` | `U+2563` | Box Drawings Double Vertical And Left | `E2 95 A3` | | 186 | `BA` | `10111010` | `║` | `U+2551` | Box Drawings Double Vertical | `E2 95 91` | | 187 | `BB` | `10111011` | `╗` | `U+2557` | Box Drawings Double Down And Left | `E2 95 97` | | 188 | `BC` | `10111100` | `╝` | `U+255D` | Box Drawings Double Up And Left | `E2 95 9D` | | 189 | `BD` | `10111101` | `╜` | `U+255C` | Box Drawings Up Double And Left Single | `E2 95 9C` | | 190 | `BE` | `10111110` | `╛` | `U+255B` | Box Drawings Up Single And Left Double | `E2 95 9B` | | 191 | `BF` | `10111111` | `┐` | `U+2510` | Box Drawings Light Down And Left | `E2 94 90` | | 192 | `C0` | `11000000` | `└` | `U+2514` | Box Drawings Light Up And Right | `E2 94 94` | | 193 | `C1` | `11000001` | `┴` | `U+2534` | Box Drawings Light Up And Horizontal | `E2 94 B4` | | 194 | `C2` | `11000010` | `┬` | `U+252C` | Box Drawings Light Down And Horizontal | `E2 94 AC` | | 195 | `C3` | `11000011` | `├` | `U+251C` | Box Drawings Light Vertical And Right | `E2 94 9C` | | 196 | `C4` | `11000100` | `─` | `U+2500` | Box Drawings Light Horizontal | `E2 94 80` | | 197 | `C5` | `11000101` | `┼` | `U+253C` | Box Drawings Light Vertical And Horizontal | `E2 94 BC` | | 198 | `C6` | `11000110` | `╞` | `U+255E` | Box Drawings Vertical Single And Right Double | `E2 95 9E` | | 199 | `C7` | `11000111` | `╟` | `U+255F` | Box Drawings Vertical Double And Right Single | `E2 95 9F` | | 200 | `C8` | `11001000` | `╚` | `U+255A` | Box Drawings Double Up And Right | `E2 95 9A` | | 201 | `C9` | `11001001` | `╔` | `U+2554` | Box Drawings Double Down And Right | `E2 95 94` | | 202 | `CA` | `11001010` | `╩` | `U+2569` | Box Drawings Double Up And Horizontal | `E2 95 A9` | | 203 | `CB` | `11001011` | `╦` | `U+2566` | Box Drawings Double Down And Horizontal | `E2 95 A6` | | 204 | `CC` | `11001100` | `╠` | `U+2560` | Box Drawings Double Vertical And Right | `E2 95 A0` | | 205 | `CD` | `11001101` | `═` | `U+2550` | Box Drawings Double Horizontal | `E2 95 90` | | 206 | `CE` | `11001110` | `╬` | `U+256C` | Box Drawings Double Vertical And Horizontal | `E2 95 AC` | | 207 | `CF` | `11001111` | `╧` | `U+2567` | Box Drawings Up Single And Horizontal Double | `E2 95 A7` | | 208 | `D0` | `11010000` | `╨` | `U+2568` | Box Drawings Up Double And Horizontal Single | `E2 95 A8` | | 209 | `D1` | `11010001` | `╤` | `U+2564` | Box Drawings Down Single And Horizontal Double | `E2 95 A4` | | 210 | `D2` | `11010010` | `╥` | `U+2565` | Box Drawings Down Double And Horizontal Single | `E2 95 A5` | | 211 | `D3` | `11010011` | `╙` | `U+2559` | Box Drawings Up Double And Right Single | `E2 95 99` | | 212 | `D4` | `11010100` | `╘` | `U+2558` | Box Drawings Up Single And Right Double | `E2 95 98` | | 213 | `D5` | `11010101` | `╒` | `U+2552` | Box Drawings Down Single And Right Double | `E2 95 92` | | 214 | `D6` | `11010110` | `╓` | `U+2553` | Box Drawings Down Double And Right Single | `E2 95 93` | | 215 | `D7` | `11010111` | `╫` | `U+256B` | Box Drawings Vertical Double And Horizontal Single | `E2 95 AB` | | 216 | `D8` | `11011000` | `╪` | `U+256A` | Box Drawings Vertical Single And Horizontal Double | `E2 95 AA` | | 217 | `D9` | `11011001` | `┘` | `U+2518` | Box Drawings Light Up And Left | `E2 94 98` | | 218 | `DA` | `11011010` | `┌` | `U+250C` | Box Drawings Light Down And Right | `E2 94 8C` | | 219 | `DB` | `11011011` | `█` | `U+2588` | Full Block | `E2 96 88` | | 220 | `DC` | `11011100` | `▄` | `U+2584` | Lower Half Block | `E2 96 84` | | 221 | `DD` | `11011101` | `▌` | `U+258C` | Left Half Block | `E2 96 8C` | | 222 | `DE` | `11011110` | `▐` | `U+2590` | Right Half Block | `E2 96 90` | | 223 | `DF` | `11011111` | `▀` | `U+2580` | Upper Half Block | `E2 96 80` | | 224 | `E0` | `11100000` | `α` | `U+03B1` | Greek Small Letter Alpha | `CE B1` | | 225 | `E1` | `11100001` | `ß` | `U+00DF` | Latin Small Letter Sharp S | `C3 9F` | | 226 | `E2` | `11100010` | `Γ` | `U+0393` | Greek Capital Letter Gamma | `CE 93` | | 227 | `E3` | `11100011` | `π` | `U+03C0` | Greek Small Letter Pi | `CF 80` | | 228 | `E4` | `11100100` | `Σ` | `U+03A3` | Greek Capital Letter Sigma | `CE A3` | | 229 | `E5` | `11100101` | `σ` | `U+03C3` | Greek Small Letter Sigma | `CF 83` | | 230 | `E6` | `11100110` | `µ` | `U+00B5` | Micro Sign | `C2 B5` | | 231 | `E7` | `11100111` | `τ` | `U+03C4` | Greek Small Letter Tau | `CF 84` | | 232 | `E8` | `11101000` | `Φ` | `U+03A6` | Greek Capital Letter Phi | `CE A6` | | 233 | `E9` | `11101001` | `Θ` | `U+0398` | Greek Capital Letter Theta | `CE 98` | | 234 | `EA` | `11101010` | `Ω` | `U+03A9` | Greek Capital Letter Omega | `CE A9` | | 235 | `EB` | `11101011` | `δ` | `U+03B4` | Greek Small Letter Delta | `CE B4` | | 236 | `EC` | `11101100` | `∞` | `U+221E` | Infinity | `E2 88 9E` | | 237 | `ED` | `11101101` | `φ` | `U+03C6` | Greek Small Letter Phi | `CF 86` | | 238 | `EE` | `11101110` | `ε` | `U+03B5` | Greek Small Letter Epsilon | `CE B5` | | 239 | `EF` | `11101111` | `∩` | `U+2229` | Intersection | `E2 88 A9` | | 240 | `F0` | `11110000` | `≡` | `U+2261` | Identical To | `E2 89 A1` | | 241 | `F1` | `11110001` | `±` | `U+00B1` | Plus-Minus Sign | `C2 B1` | | 242 | `F2` | `11110010` | `≥` | `U+2265` | Greater-Than Or Equal To | `E2 89 A5` | | 243 | `F3` | `11110011` | `≤` | `U+2264` | Less-Than Or Equal To | `E2 89 A4` | | 244 | `F4` | `11110100` | `⌠` | `U+2320` | Top Half Integral | `E2 8C A0` | | 245 | `F5` | `11110101` | `⌡` | `U+2321` | Bottom Half Integral | `E2 8C A1` | | 246 | `F6` | `11110110` | `÷` | `U+00F7` | Division Sign | `C3 B7` | | 247 | `F7` | `11110111` | `≈` | `U+2248` | Almost Equal To | `E2 89 88` | | 248 | `F8` | `11111000` | `°` | `U+00B0` | Degree Sign | `C2 B0` | | 249 | `F9` | `11111001` | `∙` | `U+2219` | Bullet Operator | `E2 88 99` | | 250 | `FA` | `11111010` | `·` | `U+00B7` | Middle Dot | `C2 B7` | | 251 | `FB` | `11111011` | `√` | `U+221A` | Square Root | `E2 88 9A` | | 252 | `FC` | `11111100` | `ⁿ` | `U+207F` | Superscript Latin Small Letter N | `E2 81 BF` | | 253 | `FD` | `11111101` | `²` | `U+00B2` | Superscript Two | `C2 B2` | | 254 | `FE` | `11111110` | `■` | `U+25A0` | Black Square | `E2 96 A0` | | 255 | `FF` | `11111111` | ` ` | `U+00A0` | No-Break Space | `C2 A0` | ## ASCII and Unicode Unicode assigns a number, called a code point and written `U+` followed by hex, to every character in every script. It currently defines about 155,000 of them, with room for 1,114,112. The first 128 Unicode code points are exactly ASCII, deliberately and permanently: ```text 'A' ASCII 65 = U+0041 '~' ASCII 126 = U+007E ``` So ASCII is a subset of Unicode. What changes is how those code points become bytes, which is the job of an encoding. ### UTF-8 UTF-8 encodes a code point as one to four bytes, and it was designed specifically so that ASCII would survive untouched: | Code point range | Bytes | Bit pattern | | --- | ---: | --- | | `U+0000` to `U+007F` | 1 | `0xxxxxxx` | | `U+0080` to `U+07FF` | 2 | `110xxxxx 10xxxxxx` | | `U+0800` to `U+FFFF` | 3 | `1110xxxx 10xxxxxx 10xxxxxx` | | `U+10000` to `U+10FFFF` | 4 | `11110xxx 10xxxxxx 10xxxxxx 10xxxxxx` | Read off the consequences: - Any code point below 128 is a single byte with the top bit clear, identical to its ASCII byte. **Every ASCII file is already a valid UTF-8 file**, byte for byte, with no conversion. - Any byte with the top bit set is part of a multi-byte sequence. An ASCII character can therefore never appear as part of a longer character, so searching for `/` or `\n` in UTF-8 with a plain byte scan is safe. That property is why UTF-8 could be adopted without rewriting every Unix tool. - The first byte of a sequence tells you its length, and continuation bytes always start `10`, so you can find a character boundary from anywhere in the stream by scanning backwards. - The number of bytes is not the number of characters. `len()` on a byte string and `len()` on a text string answer different questions, and conflating them is the most common Unicode bug. Worked example, the euro sign `U+20AC`: ```text U+20AC = 0010 0000 1010 1100 (16 bits, so three bytes) split: 0010 000010 101100 prefix: 1110xxxx 10xxxxxx 10xxxxxx result: 11100010 10000010 10101100 hex: E2 82 AC ``` ### Encoding a file, and what goes wrong ```python "café".encode("utf-8") # b'caf\xc3\xa9' 4 characters, 5 bytes "café".encode("latin-1") # b'caf\xe9' 4 characters, 4 bytes "café".encode("ascii") # UnicodeEncodeError: ordinal not in range(128) ``` The classic failure is text encoded as UTF-8 and decoded as Windows-1252. Each byte above 127 gets shown separately, so one character becomes two or three: | Intended | UTF-8 bytes | Read as Windows-1252 | | --- | --- | --- | | `é` | `C3 A9` | `é` | | `’` | `E2 80 99` | `’` | | `€` | `E2 82 AC` | `€` | If you see `Ã` or `â€` in output, that pattern is the diagnosis: UTF-8 bytes read as a single-byte code page. The fix is at the point of decoding, not by find-and-replace on the damaged text. > **Sensible defaults** > > Use UTF-8 everywhere: source files, database columns, HTTP headers, file reads. Declare it > explicitly rather than relying on the platform default, which differs between Windows and > everything else. In Python that means `open(path, encoding="utf-8")`, and in HTML it means > `` in the first 1024 bytes of the document. ## Escape sequences Because control characters cannot be typed into a string literal, every language provides backslash escapes. The common core came from C and has been copied almost everywhere. | Escape | Character | Dec | C and C++ | Python | Java | JavaScript | Go | | --- | --- | ---: | --- | --- | --- | --- | --- | | `\0` | NUL | 0 | yes | yes | yes (octal) | yes | `\x00` | | `\a` | Bell | 7 | yes | yes | no | no | yes | | `\b` | Backspace | 8 | yes | yes | yes | yes | yes | | `\t` | Tab | 9 | yes | yes | yes | yes | yes | | `\n` | Line feed | 10 | yes | yes | yes | yes | yes | | `\v` | Vertical tab | 11 | yes | yes | no | yes | yes | | `\f` | Form feed | 12 | yes | yes | yes | yes | yes | | `\r` | Carriage return | 13 | yes | yes | yes | yes | yes | | `\e` | Escape | 27 | GNU extension | no | no | no | no | | `\"` | Double quote | 34 | yes | yes | yes | yes | yes | | `\'` | Apostrophe | 39 | yes | yes | yes | yes | yes | | `\\` | Backslash | 92 | yes | yes | yes | yes | yes | | `\xHH` | Hex byte | any | yes | yes | no | yes | yes | | `\nnn` | Octal | any | yes | yes | yes | deprecated | yes | | `\uXXXX` | Unicode, 4 hex | any | `\uXXXX` | yes | yes | yes | yes | Where a language has no `\e`, write `\x1b` in C-family languages, `\033` where octal is supported, or `\u001b` in Java. Python and JavaScript both accept `\x1b`, `\033` and `\u001b`. ## ANSI escape codes The most visible modern use of a control character. ESC (27) followed by `[` starts a Control Sequence Introducer, and terminals interpret what follows as a command rather than text. This is how every coloured command line tool works. The sequence is written `ESC [` in prose, `\033[` in C and shell, `\x1b[` in Python and JavaScript, and shows up as `^[[` when a terminal prints it literally. ### Colours and styles Set Graphic Rendition takes one or more numbers separated by semicolons and ends with `m`. | Code | Effect | Code | Effect | | ---: | --- | ---: | --- | | 0 | Reset everything | 30-37 | Foreground black, red, green, yellow, blue, magenta, cyan, white | | 1 | Bold or bright | 40-47 | Background, same eight colours | | 2 | Dim | 90-97 | Bright foreground | | 3 | Italic | 100-107 | Bright background | | 4 | Underline | 39 | Default foreground | | 7 | Reverse video | 49 | Default background | | 9 | Strikethrough | `38;5;n` | 256-colour foreground, n is 0-255 | | 22 | Normal intensity | `48;5;n` | 256-colour background | | 24 | Underline off | `38;2;r;g;b` | 24-bit foreground | | 27 | Reverse off | `48;2;r;g;b` | 24-bit background | ```bash printf '\033[1;31merror\033[0m: something broke\n' # bold red word printf '\033[38;2;255;140;0morange\033[0m\n' # true colour ``` Always emit the reset (`\033[0m`) or the styling leaks into whatever the terminal prints next. ### Cursor and screen control | Sequence | Effect | | --- | --- | | `ESC [ n A` | Cursor up n rows | | `ESC [ n B` | Cursor down n rows | | `ESC [ n C` | Cursor right n columns | | `ESC [ n D` | Cursor left n columns | | `ESC [ r ; c H` | Move cursor to row r, column c, counting from 1 | | `ESC [ 2 J` | Clear the whole screen | | `ESC [ K` | Clear from the cursor to the end of the line | | `ESC [ s` | Save the cursor position | | `ESC [ u` | Restore the saved cursor position | | `ESC [ ? 25 l` | Hide the cursor | | `ESC [ ? 25 h` | Show the cursor | Combining carriage return with "clear to end of line" is how progress bars redraw in place: `\r\033[K` puts you back at column one and wipes what was there. > **Do not hardcode colours into piped output** > > Check whether the output is a terminal before emitting escape codes. If the output is redirected > to a file, the codes get written literally and pollute the data. In C that is `isatty(1)`, in > Python `sys.stdout.isatty()`. Most command line tools also honour a `NO_COLOR` environment > variable. ## Practical gotchas Things that cost people real time: 1. **`char` may be signed.** In C, plain `char` is signed on most platforms, so a byte above 127 becomes negative. Passing it to `isalpha` or `toupper` is undefined behaviour. Cast to `unsigned char` first: `toupper((unsigned char) c)`. 2. **The Backspace key sends DEL, not BS.** Code 127, not code 8. Terminal configuration (`stty erase`) decides, and mismatches are why backspace sometimes prints `^?` over SSH. 3. **`\n` is not always one byte on disk.** On Windows, text mode translates it to CRLF on write. If you compute a file length from string lengths, it will be wrong. 4. **A trailing `\r` is invisible.** Compare strings after stripping, and if a comparison fails for no visible reason, print `repr()` of both sides. 5. **Curly quotes are not ASCII.** `"` from a word processor is U+201C, not code 34. Pasting code from a document produces syntax errors that look like nothing is wrong. 6. **No-break space is not space.** U+00A0 survives copy and paste from web pages, looks identical, and fails `== " "` and often `strip()`. 7. **Sorting is not alphabetical.** Byte order puts all uppercase before all lowercase, and puts digits before letters. Use a locale-aware collation for anything a user will read. 8. **NUL terminates C strings.** Any data containing a zero byte cannot round-trip through a `char *` API. This is a real security issue when a language that allows embedded NULs hands a string to a C library that does not. 9. **`isdigit` is not `isdigit` in Unicode.** Python's `str.isdigit()` returns true for superscripts and other scripts' digits. Use `str.isascii() and str.isdigit()` if you mean the ASCII ten. 10. **Case conversion is not always a bit flip.** Turkish dotless i, German sharp s and Greek final sigma all break the assumption that case changes one character to one character. Only the ASCII range is safe. ## Where ASCII shows up ### Base64 Base64 exists to push arbitrary binary through channels that only survive ASCII, such as email bodies and URLs. It takes three bytes (24 bits) at a time, splits them into four 6-bit groups, and maps each group to one of 64 printable characters. Output is therefore about 33 percent larger than the input, and it is padded with `=` to a multiple of four. **The standard Base64 alphabet (RFC 4648)** | Val | Char | Val | Char | Val | Char | Val | Char | | ---: | :---: | ---: | :---: | ---: | :---: | ---: | :---: | | 0 | `A` | 16 | `Q` | 32 | `g` | 48 | `w` | | 1 | `B` | 17 | `R` | 33 | `h` | 49 | `x` | | 2 | `C` | 18 | `S` | 34 | `i` | 50 | `y` | | 3 | `D` | 19 | `T` | 35 | `j` | 51 | `z` | | 4 | `E` | 20 | `U` | 36 | `k` | 52 | `0` | | 5 | `F` | 21 | `V` | 37 | `l` | 53 | `1` | | 6 | `G` | 22 | `W` | 38 | `m` | 54 | `2` | | 7 | `H` | 23 | `X` | 39 | `n` | 55 | `3` | | 8 | `I` | 24 | `Y` | 40 | `o` | 56 | `4` | | 9 | `J` | 25 | `Z` | 41 | `p` | 57 | `5` | | 10 | `K` | 26 | `a` | 42 | `q` | 58 | `6` | | 11 | `L` | 27 | `b` | 43 | `r` | 59 | `7` | | 12 | `M` | 28 | `c` | 44 | `s` | 60 | `8` | | 13 | `N` | 29 | `d` | 45 | `t` | 61 | `9` | | 14 | `O` | 30 | `e` | 46 | `u` | 62 | `+` | | 15 | `P` | 31 | `f` | 47 | `v` | 63 | `/` | The URL-safe variant of RFC 4648 replaces `+` with `-` and `/` with `_`, so the result can go in a query string or filename without escaping. ### Percent encoding in URLs RFC 3986 splits ASCII into characters a URL may contain literally and characters that must be written as `%` followed by two hex digits. | Class | Characters | In a URL | | --- | --- | --- | | Unreserved | `A-Z a-z 0-9 - . _ ~` | Always safe, never needs encoding | | Reserved, generic | `: / ? # [ ] @` | Safe only in their structural role | | Reserved, sub-delimiters | `! $ & ' ( ) * + , ; =` | Encode inside a value | | Everything else | space, `"`, `<`, `>`, `\`, `^`, backtick, `{`, `\|`, `}`, and all controls | Must be percent-encoded | Space is `%20`, or `+` in the older `application/x-www-form-urlencoded` form-data format only. `#` is `%23`, `&` is `%26`, and `%` itself is `%25`. ### Regular expression character classes POSIX classes map directly onto ranges of this table, which is worth seeing written out: | Class | ASCII range | Equivalent | | --- | --- | --- | | `[:digit:]` | 48-57 | `[0-9]` | | `[:upper:]` | 65-90 | `[A-Z]` | | `[:lower:]` | 97-122 | `[a-z]` | | `[:alpha:]` | 65-90, 97-122 | `[A-Za-z]` | | `[:alnum:]` | 48-57, 65-90, 97-122 | `[0-9A-Za-z]` | | `[:xdigit:]` | 48-57, 65-70, 97-102 | `[0-9A-Fa-f]` | | `[:punct:]` | 33-47, 58-64, 91-96, 123-126 | Printable, not alphanumeric, not space | | `[:space:]` | 9-13, 32 | `[ \t\n\v\f\r]` | | `[:cntrl:]` | 0-31, 127 | The control characters | | `[:print:]` | 32-126 | Everything with a visible form, plus space | | `[:graph:]` | 33-126 | Printable excluding space | | `[:ascii:]` | 0-127 | The whole table | Note that `\w` in most engines means `[A-Za-z0-9_]`, which includes the underscore. In Unicode-aware mode it means far more than that, so `\w` and `[:alpha:]` are not interchangeable. ### Other places it hangs around - **HTTP** is defined in terms of ASCII. Methods, header names and status lines are all ASCII, and header values were historically restricted to it. - **DNS** hostnames are ASCII only, which is why internationalised domain names are encoded into ASCII by Punycode before they go on the wire. - **Source code** in most languages restricts identifiers to ASCII or near it, and every language keyword is ASCII. - **MIME quoted-printable** encodes a non-ASCII byte as `=` followed by two hex digits, the same idea as percent encoding. - **`ROT13`** rotates a letter 13 places within its case run, relying on the fact that each run is contiguous and 26 long. - **Checksums and hashes** are usually shown as hex, which is itself ASCII text describing binary. ## A short history > **From teleprinters to the web** > > **1961.** Bob Bemer of IBM submits a proposal to the American Standards Association for a common > character code. He later campaigned for the escape character, and was nicknamed the Father of > ASCII. > > **1963.** The first standard, ASA X3.4-1963, is published. It has holes: the lowercase letters > are not yet assigned. > > **1965.** A revision is approved but never actually published, having been overtaken by events. > > **1967.** ASA X3.4-1967 adds the lowercase letters and settles the layout that survives today. > > **1968.** President Lyndon Johnson mandates that all computers bought by the federal government > support ASCII, which effectively ends the competing codes outside IBM's own mainframes, where > EBCDIC continues. > > **1972.** The C programming language bakes several ASCII assumptions into common practice, notably > NUL termination and the backslash escapes. > > **1986.** ANSI X3.4-1986 is published. This is the version still in force. ASCII has not changed > since. > > **1991.** Unicode 1.0 arrives, with ASCII as its first 128 code points. > > **1992.** Ken Thompson and Rob Pike design UTF-8, reportedly on a placemat in a New Jersey diner, > specifically so that ASCII text remains valid without change. > > **2008.** UTF-8 overtakes every other encoding on the web. As of the mid 2020s it is used by > well over 98 percent of websites, and every one of those pages still contains ASCII underneath. Two names are worth attaching to the design. The 32 gap between cases and the placement of the control characters were chosen so that the encoding would be easy to manipulate with the simple logic circuits of the early 1960s, and the same choices are what make the bit tricks on this page work sixty years later. Good encodings age well. ## Glossary | Term | Meaning | | --- | --- | | **ASCII** | American Standard Code for Information Interchange. A 7-bit code defining 128 characters. | | **Byte** | Eight bits on any machine you will use. Historically the size varied, which is why network standards say "octet". | | **Character set** | The collection of characters and the numbers assigned to them. | | **Code page** | An older term, mostly IBM and Microsoft, for a particular 8-bit character set such as CP437 or CP1252. | | **Code point** | The number assigned to a character. ASCII has 128, Unicode has room for 1,114,112. | | **Code unit** | The fixed-size piece an encoding works in: 8 bits for UTF-8, 16 for UTF-16. | | **Collation** | The rules for ordering strings for a human reader, as opposed to sorting by byte value. | | **Control character** | A code point that commands a device rather than representing a printable symbol. | | **EBCDIC** | IBM's competing 8-bit mainframe encoding, in which the alphabet is not contiguous. Still alive on z/OS. | | **Encoding** | The rule turning code points into bytes. ASCII, UTF-8 and Latin-1 are all encodings. | | **Glyph** | The drawn shape of a character in a particular font. One character can have many glyphs. | | **Mojibake** | Text made unreadable by decoding it with the wrong encoding. Japanese for "character transformation". | | **Octet** | Exactly eight bits. Used in standards documents where "byte" would be ambiguous. | | **Parity bit** | The eighth bit on a 7-bit serial link, set so the total number of set bits is odd or even, giving basic error detection. | | **Nibble** | Four bits, that is one hex digit. | | **Unicode** | The universal character set that ASCII is now the first 128 characters of. | | **UTF-8** | The variable-width encoding of Unicode that is backwards compatible with ASCII. | ## Further reading - `man 7 ascii` on any Unix system prints the table locally, no network needed. - **ANSI X3.4-1986** is the standard itself, also published as ECMA-6 and ISO/IEC 646. - **RFC 20**, "ASCII format for Network Interchange", is the version the internet formally references, and was only promoted to Internet Standard status in 2015. - **RFC 3629** defines UTF-8, and **RFC 4648** defines Base64 and its URL-safe variant. - **The Unicode Standard**, chapter 2, explains the relationship between code points, encodings and glyphs properly. - Joel Spolsky's "The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets" remains the best short introduction to why encodings go wrong.