# Configuring ftfy

`fix_text` and `fix_and_explain` run text through a sequence of fixes. If a
pass changes the text, they run the sequence again until the result is stable.

Pass configuration as a plain object or a `TextFixerConfig`:

```ts
import { TextFixerConfig, fix_text } from "ftfy-js";

fix_text(text, { uncurl_quotes: false });
fix_text(text, new TextFixerConfig({ uncurl_quotes: false }));
```

## Settings

| Setting | Default | Meaning |
| --- | --- | --- |
| `unescape_html` | `"auto"` | Decode HTML entities. Auto disables this after a literal `<` indicates actual HTML. |
| `remove_terminal_escapes` | `true` | Remove ANSI terminal escape sequences. |
| `fix_encoding` | `true` | Detect and repair mojibake. |
| `restore_byte_a0` | `true` | Let an ASCII space stand for a lost UTF-8 continuation byte A0 when evidence is strong. |
| `replace_lossy_sequences` | `true` | Repair partially lost mojibake containing `�` or `?`. |
| `decode_inconsistent_utf8` | `true` | Repair embedded UTF-8 mojibake even when the whole string has no consistent encoding. |
| `fix_c1_controls` | `true` | Replace obsolete Latin-1 C1 controls with Windows-1252 equivalents. |
| `fix_latin_ligatures` | `true` | Expand Latin ligatures such as `ﬁ` to `fi`. |
| `fix_character_width` | `true` | Replace fullwidth Latin and halfwidth Katakana with standard-width forms. |
| `uncurl_quotes` | `true` | Replace curly quotes with straight quotes. |
| `fix_line_breaks` | `true` | Convert supported line breaks to Unix `\n`. |
| `fix_surrogates` | `true` | Preserve valid UTF-16 pairs and replace unpaired surrogates with `�`. |
| `remove_control_chars` | `true` | Remove control characters with no intended display effect. |
| `normalization` | `"NFC"` | Apply `NFC`, `NFD`, `NFKC`, or `NFKD`; use `null` for none. |
| `max_decode_length` | `1_000_000` | Maximum code-point length of a segment repaired at once. |
| `explain` | `true` | Build explanation plans. Functions returning only text disable this by default. |

The first four subordinate encoding options have no effect when `fix_encoding`
is false.

Set `unescape_html: false` when output will be interpreted as HTML. Set
`fix_character_width: false` when CJK spacing must be preserved. Set
`uncurl_quotes: false` when typographic quotation marks should remain. For a
more conservative mojibake repair, set `decode_inconsistent_utf8: false`.

The deprecated upstream name `fix_entities` is accepted as an alias for
`unescape_html`.
