TextDecoder decodes x-user-defined from a generated table
Date: 2026-12-03
Area: web, encoding, generated-data
Refines: ADR 0233, which left
x-user-defined's label a RangeError
Related: #2584, #2491,
Built-ins — TextDecoder
Context
ADR 0233 left UTF-16, x-user-defined and the legacy multi-byte encodings out, to be added each as its own decoder
when something asked for one. web-platform-tests' Encoding suites (#2491) now run in the test suite, and three of
their subtests decode x-user-defined. Its decoder is stateless and maps one byte to one code point: an ASCII byte is
itself, and byte 0x80 + i is U+F780 + i (the standard's "x-user-defined decoder"). That is exactly what the
single-byte decoder does with a 128-entry index, though indexes.json has no index for it.
Decision
- x-user-defined decodes through the single-byte decoder, with an index the generator writes.
scripts/generate-encoding-data.jsappends x-user-defined after the single-byte encodings inGenerated.EncodingData, with the index U+F780 to U+F7FF, so its label is looked up and decoded as theirs are and no new native is added. - UTF-16 and the legacy multi-byte encodings stay as ADR 0233 left them, each tracked by its own issue.
Consequences
new TextDecoder("x-user-defined")decodes, and itsencodingis"x-user-defined".- Every x-user-defined byte maps to a code point, so a fatal decoder never throws for it, as the standard says.
- The index is written by the generator, not read from whatwg/encoding; a change to the standard's x-user-defined decoder reaches the engine only through a change to the generator.