PDF text-layer mojibake hell: a field guide only tractable with coding agents
wightmanr · x · 2026-12-06
- Developer wightmanr on cleaning OCR annotations from PDFs: detecting mojibake reliably in a multilingual corpus consumed an inordinate amount of time; he doubts a 1-person team could tackle it without coding agents.
- The attached "PDF Text-Layer Hall of Horrors" catalogues real-world failure modes:
- Mixed 8-bit codepages on one page (CP1251, KOI8-R, CP1256, legacy Baltic) — naive latin1→cp1251 decoding yields plausible-looking Cyrillic garbage
- Arbitrary subset-font glyph-ID shifts with zero errors, undetectable by ffty or codepage detectors; 100% pure-ASCII legacy Indic/Georgian fonts with zero high bytes
- Valid-Unicode impostors: Vietnamese chars with perfect text-checks, Zawgyi-One inside real Unicode blocks, corrupted Indic fonts emitting valid but consonant-swapped Devanagari/Bengali/Tamil — only catchable by auditing /BaseFont + per-page Tf streams
- Cross-platform font hacks: Icelandic accents on CJK fonts, Symbol/Wingdings PUA collisions, broken LaTeX ligature/accent maps
- Silent failures: mojibake-free but wrong extractions; image-vs-label mismatch when fixing the text layer vs. rendered pixels
- A high-value pitfall map for anyone building document pipelines or cleaning OCR data.
More from coding & agent
- Agent orchestration is fatiguing engineers — and 'chief of staff' agents are next — minhnguyen · 2026-12-06
- Dev shares full Gemini swarm build plan for a local site crawler: 8 parallel workers plus adversarial verification gates — gaganghotra_ · 2026-12-06
- Why editing a Claude message kills your prompt cache: SWA checkpointing? — YouJiacheng · 2026-12-06
- Dev lets his agent set up Deadbolt straight from the repo: 'no bad UX anymore' — altryne · 2026-12-06
- Step-by-step: making an AI film with Scenario and ChatGPT, from characters to cost — aziz4ai · 2026-12-06
- Google AI Ultra spotted in OpenCode desktop app, fueling integration rumors — altryne · 2026-12-06