ASCII
ASCII is a seven-bit coded character set with 128 code positions for letters, digits, punctuation, space and control functions.
Representation: RFC 20 describes ASCII interchange in eight-bit bytes with the high bit zero. The code includes NUL, line feed and DEL, not just printable text; values 80 to FF hexadecimal are outside this seven-bit repertoire. An eight-bit storage unit does not make every possible byte an ASCII code. [1]
Compatibility: UTF-8 uses the same single-byte representation for U+0000 through U+007F. The converse does not hold: C3 A9 represents U+00E9 in UTF-8 but is rejected by a strict ASCII decoder. A byte sequence within 00 to 7F cannot, by itself, distinguish ASCII from UTF-8 or identify its original encoding. [2]
Decoder contract: WHATWG TextDecoder resolves the labels ascii and us-ascii to windows-1252. Consequently, new TextDecoder("ascii", {fatal: true}) is not a strict ASCII validator: byte 80 decodes to U+20AC under that API. Specify the API, resolved encoding and error policy, not merely a label. [3]
Buffer contract: For a Node.js Buffer instance, buf.toString("ascii") clears each byte's high bit, so 41 and C1 hexadecimal both become A. Masking also maps 80 to U+0000 and 61 AF 62 to a/b; checking only the converted output misses the original byte contract. Buffer.from(text, "ascii") uses latin1 encoding instead, so this round trip need not preserve text. [5]
Recovery: Check an ASCII-only byte contract before converting names or metadata. Passing that check says nothing about whether controls, separators or other values are permitted by the destination format. Preserve the original bytes when a display transformation is not reversible. [4]
Relations
- related
- Character encoding, UTF-8, Byte, Unicode scalar value, Filename collision, ISO-8859-1 (Latin-1), Windows-1252
Limitations
- ASCII does not represent all Unicode text, validate destination filenames or identify an unknown source encoding.
Citations
- RFC 20: ASCII format for Network Interchange, code table and control functions
- Unicode 17.0.0: chapter 2, section 2.5.3, UTF-8 and ASCII transparency
- WHATWG Encoding Standard: names and labels, windows-1252
- Hesela: ASCII byte contracts in filename recovery
- Node.js v24.22.2: Buffer, buffers and character encodings
Sources & caveats
- Source-reviewed definition with exhaustive one-byte strict-codec checks and bounded WHATWG decoder examples: https://hesela.dev/research/ascii-contracts/README.md. These are codec observations, not filesystem or backup-product tests.