How ASCII Works

ASCII (American Standard Code for Information Interchange) is a character encoding standard published in 1963. It assigns a number from 0 to 127 to each character in the English alphabet, digits, and common symbols.

The ASCII Table

ASCII codes 0–31 and 127 are control characters — non-printable signals like newline (10), carriage return (13), tab (9), and null (0). Codes 32–126 are printable: space (32), digits 48–57, uppercase A–Z at 65–90, lowercase a–z at 97–122.

Key Values to Memorize

'A' = 65, 'a' = 97, '0' = 48, space = 32. The difference between any uppercase letter and its lowercase version is exactly 32. Setting bit 5 (adding 32) lowercases a letter; clearing it uppercases it.

ASCII and Unicode

ASCII covers only 128 characters, handling English well but nothing else. Unicode extends this to over 1 million code points, covering every writing system, emoji, and technical symbol. UTF-8, the dominant web encoding, is backward-compatible with ASCII for the first 128 characters.

ASCII in Code

In C, char arithmetic like 'A' + 1 = 'B' relies on ASCII ordering. In JavaScript, String.fromCharCode(65) gives 'A', and 'A'.charCodeAt(0) gives 65. ASCII knowledge is fundamental for parsing, lexing, and low-level string manipulation.

Related Tools