# Latin-1 and Windows-1252 decoder contracts

Constructed inputs, not filesystem observations or incident frequencies.
Enumerates every one-byte input 00..FF through CPython bytes.decode with strict
latin-1/cp1252, three Node WHATWG TextDecoder labels with fatal:true, and Node
Buffer.toString("latin1"). The runtime versions, complete mappings, rejected
bytes, generation time and SHA-256 of executable sources are in results.json.

Run with Python 3 and Node (no third-party packages):
    python3 -B probe.py
    python3 -B -m unittest discover -s . -p test_probe.py
    python3 -B -O -m unittest discover -s . -p test_probe.py

To generate observations for another runtime, use python3 -B probe.py --write.
Keep all four executable/result files together. A different runtime is recorded
as a different observation; identical results do not certify every implementation.
The replay check compares behavior and source hashes, not machine version equality.

The historical CP1252 table leaves 81,8D,8F,90,9D undefined. CPython strict cp1252
rejects them. The WHATWG index supplies corresponding control code points.
Its label resolution also maps latin1 and iso-8859-1 to windows-1252. A fatal
policy therefore does not enforce the historical table's undefined positions.
Node Buffer's latin1 decoder instead maps bytes to U+0000..U+00FF. The same
runtime and label are insufficient without the API.

ISO-8859-1's graphic repertoire and a codec's full 256-value mapping are distinct
claims. Unicode's published mapping explicitly includes control characters.
Successful decoding is not encoding detection, filename validity, or proof
of the intended name. Preserve original bytes and decoding metadata. These
legacy representations are documented for recovery, not recommended for new
interchange. No source files or user filenames are used by this probe.

Primary references, accessed 2026-11-20:
- IANA character sets: https://www.iana.org/assignments/character-sets
- ISO mapping, table 2.0: https://www.unicode.org/Public/MAPPINGS/ISO8859/8859-1.TXT
- CP1252 mapping, table 2.01: https://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT
- CPython 3.12.3 implementation: https://github.com/python/cpython/blob/v3.12.3/Lib/encodings/cp1252.py
- WHATWG labels: https://encoding.spec.whatwg.org/#names-and-labels
- WHATWG index dated 2024-09-18: https://encoding.spec.whatwg.org/index-windows-1252.txt
  Identifier e56d49d9176e9a412283cf29ac9bd613f5620462f2a080a84eceaf974cfa18b7
- Node 24 Buffer encodings: https://nodejs.org/docs/latest-v24.x/api/buffer.html#buffers-and-character-encodings

All test inputs are artificial. There is no filesystem restore, encoding
detector, benchmark or full Unicode-conformance claim.

## Cross-API re-encoding control (2026-11-21)

The label alone does not make an encoder the inverse of a decoder. The separate
roundtrip.mjs probe enumerates 256 one-byte inputs through Node TextDecoder
("latin1", fatal:true), then Buffer.from(text, "latin1"). Node's Buffer encoder
truncates characters outside U+0000..U+00FF. The frozen observation changes 27
inputs: 80 -> U+20AC -> AC and 9B -> U+203A -> 3A, for example (bytes in hex).
Inputs 22, 95 and 99 all become byte 22. A Buffer-only decode/encode control
retains every input. This is a deterministic census, not an incident probability.
No filename parser, filesystem or restore product is exercised.

Run node roundtrip.mjs and node --test roundtrip.test.mjs. Regenerate only with
node roundtrip.mjs --write; keep roundtrip-results.json and both executable files.
The receipt stores all 256 outputs, runtime, timestamp and source hashes; tests
compare with the primary WHATWG mapping and Buffer's low-byte rule, and include
empty and concatenated inputs. Keep the earlier decoder evidence unchanged.

Sources: the WHATWG index and Node Buffer documentation above, rechecked
2026-11-21. Byte identity, text identity and destination validity are different
checks. A successful fatal decode provides neither an inverse encoder nor proof
that the chosen interpretation matches the original name.
