# Support for bad encodings

## Sloppy encodings

Some single-byte encodings leave byte positions undefined. Strict decoders
reject those bytes, but browsers and Windows software often preserve the
same-numbered Latin-1 control character instead. python-ftfy calls these
interoperable mappings *sloppy encodings*.

The TypeScript port ships exact generated byte maps for the sloppy encodings
used by ftfy. Undefined bytes pass through as their Latin-1 code points. Byte
`0x1a` additionally maps to U+FFFD so lossy sequences can be represented during
repair.

Codec helpers are exported from `ftfy-js/bad-codecs`.

## UTF-8 variants

The `utf-8-variants` decoder accepts standard UTF-8 plus:

- CESU-8 surrogate pairs encoded as two three-byte sequences; and
- Java's two-byte `c0 80` representation of U+0000.

It still rejects overlong encodings and isolated UTF-8 surrogate sequences.
`Utf8VariantsIncrementalDecoder` buffers incomplete special sequences across
chunks, matching upstream's streaming behavior.
