# rspeer/python-ftfy

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/rspeer-python-ftfy).**

4,043 stars · 126 forks · Python · NOASSERTION

## Links

- GitHub: https://github.com/rspeer/python-ftfy
- Homepage: http://ftfy.readthedocs.org
- awesome-repositories: https://awesome-repositories.com/repository/rspeer-python-ftfy.md

## Description

This project is a Unicode text repair tool and mojibake correction library designed to fix encoding glitches and restore original characters from mangled strings. It functions as a text encoding detector and a Unicode normalization tool to resolve issues where text has been incorrectly decoded.

The library specializes in reversing multi-layered encoding errors and repairing complex mojibake patterns. It includes capabilities for detecting lossy encoding sequences, guessing byte encodings, and decoding non-standard UTF-8 variants.

The toolset covers a broad range of text cleaning and normalization tasks, including the decoding of HTML entities and backslashed escapes, the expansion of Latin ligatures, and the standardization of character widths and line breaks. It also provides utilities for removing invisible control characters and inspecting Unicode strings by codepoint.

A command-line interface is available for repairing Unicode glitches and encoding errors within files or input streams.

## Tags

### Development Tools & Productivity

- [Mojibake Repair Utilities](https://awesome-repositories.com/f/development-tools-productivity/mojibake-repair-utilities.md) — Repairs complex, multi-layered encoding errors and mojibake patterns to restore the original intended text. ([source](https://cdn.jsdelivr.net/gh/rspeer/python-ftfy@main/README.md))
- [Unicode Text Repair Libraries](https://awesome-repositories.com/f/development-tools-productivity/unicode-text-repair-libraries.md) — Provides a comprehensive library for repairing mojibake and encoding glitches to restore intended Unicode text.
- [Byte Encoding Detectors](https://awesome-repositories.com/f/development-tools-productivity/byte-encoding-detectors.md) — Identifies the likely encoding of byte strings by checking for byte-order marks and UTF-8 validity. ([source](https://ftfy.readthedocs.io/en/latest/detect.html))
- [Character Encoding Detectors](https://awesome-repositories.com/f/development-tools-productivity/character-encoding-detectors.md) — Analyzes byte sequences to identify the most likely character encoding and detect lossy sequences.
- [Lossy Encoding Detection](https://awesome-repositories.com/f/development-tools-productivity/output-formatting-utilities/formatting-enforcement-utilities/utf-8-formatting-enforcement/utf-8-sequence-validation/lossy-encoding-detection.md) — Identifies lossy encoding sequences, such as replacement characters, to determine how text was mangled.
- [Inconsistent Encoding Repair](https://awesome-repositories.com/f/development-tools-productivity/text-encoding-utilities/inconsistent-encoding-repair.md) — Detects and resolves instances where multiple different encodings are embedded within a single text stream. ([source](https://ftfy.readthedocs.io/en/latest/fixes.html))
- [Mojibake Detection](https://awesome-repositories.com/f/development-tools-productivity/text-encoding-utilities/mojibake-detection.md) — Uses character sequence heuristics to identify likely Unicode encoding glitches and mojibake.
- [Mojibake Restoration](https://awesome-repositories.com/f/development-tools-productivity/text-encoding-utilities/mojibake-restoration.md) — Reverses multi-layered encoding errors to restore original characters from mangled UTF-8 and single-byte strings.
- [Byte Order Mark Detectors](https://awesome-repositories.com/f/development-tools-productivity/byte-order-mark-detectors.md) — Provides a mechanism to guess original text encoding by checking for signature byte-order marks.
- [Encoding Error Analyzers](https://awesome-repositories.com/f/development-tools-productivity/encoding-error-analyzers.md) — Analyzes strings to identify specific encoding errors and lists the transformations required to fix the text. ([source](https://ftfy.readthedocs.io/en/latest/explain.html))
- [Escape Sequence Decoding](https://awesome-repositories.com/f/development-tools-productivity/escape-sequence-decoding.md) — Converts hex and Unicode backslashed escape sequences into their corresponding Unicode characters. ([source](https://ftfy.readthedocs.io/en/latest/fixes.html))
- [Line Break Standardization](https://awesome-repositories.com/f/development-tools-productivity/line-break-standardization.md) — Standardizes platform-specific newline sequences like CRLF and CR into Unix-style line breaks. ([source](https://ftfy.readthedocs.io/en/latest/config.html))
- [Ligature Expansion](https://awesome-repositories.com/f/development-tools-productivity/monospaced-fonts/programming-ligature-fonts/ligature-removal-tools/ligature-expansion.md) — Decomposes single-character Latin ligatures into the individual letters they represent to fix copy-paste artifacts. ([source](https://ftfy.readthedocs.io/en/latest/fixes.html))
- [Encoding Repair CLIs](https://awesome-repositories.com/f/development-tools-productivity/text-encoding-utilities/encoding-repair-clis.md) — Provides a command-line utility for detecting and repairing mojibake and encoding glitches in files. ([source](https://ftfy.readthedocs.io/en/latest/cli.html))
- [Unicode Character Inspectors](https://awesome-repositories.com/f/development-tools-productivity/unicode-character-inspectors.md) — Analyzes Unicode strings by displaying codepoints, hexadecimal values, glyphs, and character categories. ([source](https://ftfy.readthedocs.io/en/latest/explain.html))

### Data & Databases

- [Text Cleaning](https://awesome-repositories.com/f/data-databases/client-side-data-processing/text-cleaning.md) — Cleans text data by removing invisible control characters and terminal escapes while standardizing ligatures.
- [Surrogate Pair Correctors](https://awesome-repositories.com/f/data-databases/codepoint-conversion-utilities/surrogate-pair-correctors.md) — Replaces UTF-16 surrogate pairs with correct characters to fix text decoded via obsolete standards. ([source](https://ftfy.readthedocs.io/en/latest/config.html))
- [Sloppy Encoding Mapping](https://awesome-repositories.com/f/data-databases/codepoint-conversion-utilities/unicode-encoding-utilities/sloppy-encoding-mapping.md) — Implements mapping of unassigned bytes in single-byte encodings to compatible Unicode codepoints for legacy browser interoperability.

### Programming Languages & Runtimes

- [Unicode Normalization](https://awesome-repositories.com/f/programming-languages-runtimes/unicode-normalization.md) — Standardizes character widths and combining marks to ensure consistent string representations across platforms.

### Software Engineering & Architecture

- [Recursive Encoding Reversals](https://awesome-repositories.com/f/software-engineering-architecture/string-validation-and-normalization/string-encodings/utf-16-encodings/text-encoding-and-decoding/recursive-encoding-reversals.md) — Fixes multi-layered encoding errors by recursively applying decoding and encoding cycles until the text is stable.
- [Unicode Normalizers](https://awesome-repositories.com/f/software-engineering-architecture/unicode-normalizers.md) — Standardizes UTF-8 text through character decomposition, width normalization, and resolving Latin ligatures.
- [Character Substitution Tables](https://awesome-repositories.com/f/software-engineering-architecture/lookup-table-mappings/character-substitution-tables.md) — Employs predefined dictionaries to replace ligatures and non-standard control characters with standard equivalents.
- [Character Width Normalizers](https://awesome-repositories.com/f/software-engineering-architecture/string-validation-and-normalization/speech-to-text-normalizers/character-width-normalizers.md) — Replaces halfwidth and fullwidth forms of ASCII, katakana, and Hangul with standard Unicode representations. ([source](https://ftfy.readthedocs.io/en/latest/fixes.html))
- [Control Character Normalizers](https://awesome-repositories.com/f/software-engineering-architecture/string-validation-and-normalization/speech-to-text-normalizers/character-width-normalizers/control-character-normalizers.md) — Provides utilities that map C1 control characters to Windows-1252 equivalents to ensure web-standard compatibility. ([source](https://ftfy.readthedocs.io/en/latest/fixes.html))
- [Non-Standard UTF-8 Decoding](https://awesome-repositories.com/f/software-engineering-architecture/string-validation-and-normalization/string-encodings/utf-8-internal-storage/utf-8-byte-operations/non-standard-utf-8-decoding.md) — Decodes non-standard UTF-8 variants including CESU-8 and Java-specific null character encodings. ([source](https://ftfy.readthedocs.io/en/latest/bad_encodings.html))

### Content Management & Publishing

- [Multi-Stage Text Normalizers](https://awesome-repositories.com/f/content-management-publishing/content-import-filters/import-text-cleaning/multi-stage-text-normalizers.md) — Processes text through a sequence of cleaning, decoding, and normalizing steps to resolve mixed encoding glitches.

### User Interface & Experience

- [HTML Entity Processors](https://awesome-repositories.com/f/user-interface-experience/html-content-processing/html-content-processing/html-entity-processors.md) — Converts HTML entity sequences and backslashed escapes into their corresponding Unicode characters.

### Part of an Awesome List

- [Natural Language Processing](https://awesome-repositories.com/f/awesome-lists/ai/natural-language-processing.md) — Utility for fixing Unicode glitches and mojibake.
- [General Utilities](https://awesome-repositories.com/f/awesome-lists/devtools/general-utilities.md) — Tool for fixing broken Unicode strings.
- [Text Processing](https://awesome-repositories.com/f/awesome-lists/devtools/text-processing.md) — Fixes broken Unicode text to make it consistent.
