English — Official English version of
encoding-fix.
Encoding Fix (English)
Repairs mojibake (double/triple encoded UTF-8) caused by Windows cp1252/Latin-1 misinterpretation. Zero dependencies — Python stdlib only.
Typical Problem
"ue" (U+00FC) -> UTF-8 \xc3\xbc -> read as cp1252 -> "ü"
Usage
As Library
from encoding_fix import sanitize_outbound
clean = sanitize_outbound("Würge") # -> "Wuerge"
Subprocess Output
from encoding_fix import sanitize_subprocess_output
text = sanitize_subprocess_output(process.stdout)
CLI
python encoding_fix.py "Würge" # Check a single string
python encoding_fix.py # Self-test
Features
- Idempotent: Correctly encoded text is not modified
- Up to 3 rounds: Repairs even triple-encoded strings
- Subprocess decoder: UTF-8/cp1252 fallback for process output
- Zero dependencies: Python stdlib only
Changelog
1.0.0 (2026-03-12)
- Ported from BACH system/tools/encoding_fix.py