How to Fix Broken Characters in Text
Broken characters almost always mean text encoded as UTF-8 was read as something else. The pattern tells you which: é in place of é means UTF-8 read as Windows-1252, and a black diamond question mark means bytes that were not valid in the encoding used. Fix the declared encoding first, and only clean the text if the original is unrecoverable.
Text Cleaner
Strip formatting, smart quotes and invisible characters.
Garbled text has a small number of causes and each leaves a recognisable fingerprint. Learning to read the fingerprint is faster than guessing, because it tells you where in the pipeline the damage happened — and whether it can still be undone.
The important distinction is between text that is merely displayed wrongly and text that has been irreversibly damaged. Mojibake usually means the bytes are intact and only the interpretation is wrong, which is fixable. A replacement character means information was already thrown away.
Step by step
-
Read the fingerprint
é, è or ’ means UTF-8 was read as Windows-1252 — the bytes survive and the fix is the declared encoding. A replacement character or a bare question mark means bytes were dropped during a conversion and the original is gone.
-
Fix the declaration, not the text
If the bytes are intact, the repair is upstream: the charset in a Content-Type header, a meta tag, a database connection charset, or the encoding argument when the file was read. Editing the visible characters treats the symptom.
-
Check for invisible characters
Zero-width spaces, non-breaking spaces and byte-order marks are invisible but break comparisons, searches and imports. Text pasted from a web page or a word processor routinely carries them.
-
Normalise smart punctuation
Word processors substitute curly quotes, en and em dashes and ellipses. They are valid characters, but they break code, CSV parsing and exact-match lookups. Convert them to their plain equivalents when the text is destined for a machine.
-
Inspect the actual code points
When two strings look identical but do not match, escape both to see the code points. That exposes a non-breaking space masquerading as a space, or an accented letter written as a base letter plus a combining mark.
Example
The first is recoverable — the bytes are intact. The second is not.
Symptom
Café résumé
Caf? r?sum?
Cause and fix
UTF-8 read as Windows-1252.
Bytes intact — fix the declared
encoding and it reads correctly.
Converted to an encoding that had
no room for those characters.
The original is unrecoverable.
Frequently asked questions
Why does é show as é?
Can I recover text showing question marks?
What is a byte-order mark?
Why do two identical-looking strings not match?
How do I stop this happening again?
Tools used in this guide
All tools →- Text Cleaner Strip formatting, smart quotes and invisible characters. In your browser
- Unicode Escape and Unescape Convert characters to \uXXXX escapes and back. In your browser
- HTML Entity Encoder and Decoder Escape HTML special characters, or decode entities back. In your browser
- Text to Binary Converter Convert text to binary, hex, octal or decimal and back. In your browser
- Find and Replace Replace text everywhere, with optional regex support. In your browser
Related guides
All guides →Last reviewed .