# ftfy: fixes text for you

*TypeScript port of python-ftfy 6.3.1*

> “Assume all external input is the result of (a series of) bugs.” —
> [RFC 9225: Software Defects Considered Harmful](https://www.rfc-editor.org/rfc/rfc9225.html)

ftfy fixes Unicode that is broken in various ways. Its goal is to take in bad
Unicode and output good Unicode for use in Unicode-aware code.

This is different from taking in non-Unicode bytes and outputting Unicode. You
are better off when input is decoded properly and has no glitches, but often
the input is outside your control: someone else's mistake becomes your problem.

The ftfy heuristic was designed—not machine-learned—by Robyn Speer. This
TypeScript package ports that work and retains its Python-style API names.

## Documentation

- [Fixing problems and getting explanations](explain.md)
- [Configuring ftfy](config.md)
- [Encodings ftfy can handle](encodings.md)
- [Individual fixer functions](fixes.md)
- [Is ftfy an encoding detector?](detect.md)
- [How to avoid producing mojibake](avoid.md)
- [Heuristics for detecting mojibake](heuristic.md)
- [Support for bad encodings](bad-encodings.md)
- [Command-line usage](cli.md)
- [Citing ftfy](cite.md)
- [Port provenance and compatibility](porting.md)

## Quick examples

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

fix_text("âœ” No problems");
// "✔ No problems"

fix_text("The Mona Lisa doesnÃƒÂ¢Ã¢â€šÂ¬Ã¢â€žÂ¢t have eyebrows.");
// "The Mona Lisa doesn't have eyebrows."

fix_text("l’humanitÃ©");
// "l'humanité"

fix_text("P&EACUTE;REZ");
// "PÉREZ"
```

These fixes are not applied indiscriminately. Avoiding false positives is a
strong goal inherited from upstream; correctly decoded text such as
`IL Y MARQUÉ…` is unchanged.
