ASCII

Also known as: American Standard Code for Information Interchange

On this page 7

ASCII, the American Standard Code for Information Interchange, is a 7-bit character encoding that assigns numeric codes 0 to 127 to English letters, decimal digits, punctuation and control characters. In software interoperability, ASCII is the lowest common denominator of text: almost every operating system, protocol and file format can read and write it without conversion.

First published in 1963 and revised in 1967 and 1986, ASCII became the foundation for later encodings. Its 128 code points form the first block of Unicode, and UTF-8 encodes them as identical single bytes, which is why plain ASCII files remain valid UTF-8 without modification.

How the ASCII code table is organized

The ASCII table divides its 128 positions into 33 control codes and 95 printable characters. Codes 0 to 31 and code 127 control devices or data streams, while codes 32 to 126 represent the space, digits, letters and symbols that appear on screen or paper.

The layout is deliberate. Digits 0 to 9 occupy codes 48 to 57, so subtracting 48 converts a digit character into its numeric value. Uppercase and lowercase letters differ by exactly 32, a single bit, which makes case conversion a simple bitwise operation. The table below summarizes the main ranges.

Decimal rangeHexadecimalContent
0 to 3100 to 1FControl characters such as tab and line feed
3220Space
33 to 4721 to 2FPunctuation and symbols
48 to 5730 to 39Digits 0 to 9
65 to 9041 to 5AUppercase letters A to Z
97 to 12261 to 7ALowercase letters a to z
1277FDelete control character
ASCII code ranges and their content

Because ASCII needs only seven bits, the eighth bit of a byte stays unused. Early transmission systems used it for parity checking, and later vendors filled it with additional characters, which created the many incompatible extended encodings discussed below.

Control characters that still matter

Most of the 33 ASCII control codes were designed for teletypes and serial terminals, and few remain in everyday use. The survivors, however, are central to text processing, file formats and network protocols, and they cause a large share of interoperability bugs.

This table lists the control characters a developer or administrator still encounters regularly.

CodeNameCommon use today
0 (NUL)NullString terminator in C and related languages
9 (HT)Horizontal tabIndentation and tab-separated values
10 (LF)Line feedLine ending on Unix, Linux and macOS
13 (CR)Carriage returnPaired with LF as the Windows line ending
27 (ESC)EscapeStarts terminal color and cursor sequences
127 (DEL)DeleteRarely used; sometimes mapped to backspace
Control characters in current use

The difference between LF and the CR LF pair is the most common ASCII-related compatibility problem. A script saved with Windows line endings may fail on a Linux server with errors about unexpected characters, and version control systems such as Git offer settings that normalize line endings on commit and checkout. The Newline concept deserves careful attention in any cross-platform project.

ASCII compared with extended encodings and Unicode

ASCII covers only unaccented English text, so other languages required larger encodings. The resulting history explains why text that looks correct on one system becomes garbled on another, the effect known as Mojibake.

The comparison below places ASCII alongside the encodings that extended or replaced it.

EncodingBits per characterCharacters coveredRelationship to ASCII
ASCII7128The baseline standard
ISO 8859-1 (Latin-1)8256First 128 codes identical
Windows-12528256Superset of ASCII; differs from Latin-1 in 128 to 159
UTF-88 to 32, variableAll of UnicodeByte-identical for codes 0 to 127
UTF-1616 or 32, variableAll of UnicodeNot byte-compatible; uses two-byte units
EBCDIC8256Incompatible IBM mainframe encoding
ASCII and related character encodings

The term “extended ASCII” is misleading, because no single extended standard exists. It loosely refers to any 8-bit encoding that keeps ASCII in the lower half, and the upper 128 positions vary by code page. A file labeled as extended ASCII therefore does not identify its encoding and must be checked before conversion.

UTF-8 owes much of its adoption to backward compatibility with ASCII. Software that treats text as ASCII bytes generally handles UTF-8 safely as long as it does not split multibyte sequences, which allowed the transition to Unicode to proceed without rewriting every tool.

Where ASCII remains the interoperability baseline

Many protocols and formats still require or assume ASCII for structural elements, even when they carry Unicode content. Keeping identifiers and syntax within ASCII avoids ambiguity across systems, languages and keyboards.

  • Internet protocol headers in HTTP, SMTP and similar protocols are defined in ASCII, and binary or non-English content is wrapped through encodings such as Base64 or MIME headers.
  • Domain names are stored in ASCII; internationalized names are converted with Punycode into an ASCII form beginning with xn--.
  • Programming language syntax, keywords and most source code conventions rely on ASCII, even where identifiers may use Unicode.
  • Configuration files and CSV exports are most portable when restricted to ASCII, especially for older or embedded systems.

Restricting file names to ASCII letters, digits, hyphens and underscores remains a practical safeguard for data portability. Archive tools, backup systems and older file systems handle non-ASCII names inconsistently, and such names often break during transfer between platforms.

Limitations and common mistakes

ASCII is reliable precisely because it is small, but that small size creates predictable failures when systems assume ASCII where richer text exists. The following list covers the errors practitioners see most often.

  • Assuming one byte equals one character breaks string length checks, truncation and indexing once UTF-8 text enters the system.
  • Stripping non-ASCII characters to avoid errors silently corrupts names, addresses and accented words.
  • Mislabeling Windows-1252 text as ASCII produces wrong quotation marks and dashes after conversion.
  • Ignoring mixed line endings causes failing scripts, noisy version control diffs and parsing errors.

The sound approach is to treat ASCII as a subset, not a default: declare UTF-8 explicitly, validate input encodings at system boundaries and reserve pure ASCII for identifiers, protocol syntax and other places where strict portability outweighs expressiveness.

The short version

Computers store everything as numbers, so text needs an agreed list that says which number means which letter. ASCII is one of the oldest and most widely shared of these lists. It gives a number to each English letter, digit, punctuation mark and a few invisible signals such as a new line.

Because nearly every computer understands this list, plain ASCII text travels almost anywhere without being garbled. Its weakness is size: it has no room for accented letters, other alphabets or emoji, which is why newer systems such as Unicode were built on top of it.

Where it makes a difference

A logistics company exchanges daily shipment files with a partner that still runs an older warehouse system expecting ASCII text. After a software update on the sending side, the export switched to UTF-8, and customer names containing characters such as é or ü began arriving as two strange symbols each, while some records failed import because a field length check counted bytes rather than characters.

The integration team agrees on a clear contract: structural fields such as order numbers, dates and status codes stay strictly ASCII, line endings are fixed to LF, and free-text fields are transliterated to ASCII for the legacy system while the full UTF-8 version is archived for newer applications. A validation step rejects any file containing unexpected bytes above code 127 in structural fields.

Within a week, failed imports drop to zero and both companies can upgrade their systems independently without breaking the exchange.