ASCII table
ASCII table and notes about it.
1 min readSwitch Case
Full table#
Control-code reference#
A few of the control characters in the 0-31 range come up often in everyday programming:
| Code | Abbr | Name | Common use |
|---|---|---|---|
| 0 | NUL | Null | C-string terminator |
| 8 | BS | Backspace | \b in C strings |
| 9 | HT | Horizontal tab | \t |
| 10 | LF | Line feed | \n, the Unix line ending |
| 12 | FF | Form feed | \f (page break in printers) |
| 13 | CR | Carriage return | \r, half of the Windows \r\n line ending |
| 27 | ESC | Escape | First byte of ANSI escape sequences (e.g. \033[31m for red) |
| 127 | DEL | Delete | Sent by the Delete key on most terminals |
Quick patterns worth remembering#
A few relationships in the table that come up constantly in code:
'0'is 48 (0x30), soc - '0'converts an ASCII digit to its numeric value- All letters differ by exactly 0x20 between upper and lower case — this is why
tolower/touppercan be a single bitwise operation - Digits and uppercase letters are contiguous —
c >= '0' && c <= '9',c >= 'A' && c <= 'Z',c >= 'a' && c <= 'z'are single-range checks '\n'is 10,'\r'is 13 — line feed comes before carriage return
▸ stay subscribed
Liked this?
Drop your email and you'll get the next post when it's published. No tracking, one-click unsubscribe.