Fix Garbled TXT Files: Mojibake, ’ and Encoding Errors

Open the converter

You open a book and every apostrophe has turned into ’. Or café reads as café, or a perfectly normal English sentence has a Korean syllable sitting in the middle of “don’t”. This kind of scrambled text is called mojibake, and in most cases your file isn’t damaged at all. It’s being read with the wrong encoding.

Why text turns to gibberish

A text file is a series of bytes. An encoding is the table that says which byte, or group of bytes, stands for which character. Plain text files almost never say which table they used, so every program has to guess. When it guesses wrong, the bytes are still there, but they get matched to the wrong characters.

Basic English letters and digits have the same values in nearly every common encoding, which is why a file can look fine until you reach a curly quote, a dash or an accented letter. Those are the characters that give the problem away.

Identify the problem from what you see

The pattern of the damage usually tells you which encoding went wrong.

What you seeWhat it should beLikely cause
’’ (apostrophe)UTF-8 read as Windows-1252
“ and – and ” (quotes)UTF-8 read as Windows-1252
—a long dashUTF-8 read as Windows-1252
…… (ellipsis)UTF-8 read as Windows-1252
é or èé or èUTF-8 read as Windows-1252
壣UTF-8 read as Windows-1252
don뭪 or don稚don’tWindows-1252 read as an East Asian encoding
H e l l o, or squares between lettersHelloUTF-16 read as a single-byte encoding
�unknownThe character was replaced at some point and may be lost

The encodings you’re likely to run into

  • UTF-8 is the modern standard and handles every language. If you’re saving a text file today, this is the one to use.
  • Windows-1252 was the default for English and Western European text on older Windows systems, and some programs label it “ANSI”. Old fanfic archives and text files from the 2000s are often in this encoding. ISO-8859-1 is a close relative, and ordinary letters in those files read correctly as Windows-1252.
  • UTF-16 is used by some Windows tools, which may call it “Unicode”.
  • Shift_JIS (Japanese), GBK and Big5 (Chinese) and EUC-KR (Korean) are the older East Asian encodings. You’ll meet them in raw web novels and in fan translations that still contain original-language text.

The converter can read these eight: “UTF-8”, “UTF-16 LE”, “UTF-16 BE”, “Korean EUC-KR / CP949”, “Japanese Shift_JIS”, “Simplified Chinese GBK / GB18030”, “Traditional Chinese Big5” and “Western European Windows-1252”. A file in anything else, such as a Cyrillic or Central European encoding, needs converting to UTF-8 in a text editor first.

How to fix it in the converter

The converter tries to work out the encoding on its own and always shows what it picked. If it isn’t confident, the file is marked “Needs attention” and you’ll see “Please check that the text looks right”. Changing the encoding only changes how your file is read, so you can try as many as you like.

  1. Add your file and look at the preview.
  2. If you have one file, press the encoding button beside its name in the top bar. If you have several, open “Files” in the settings panel and press the encoding label on the row for that file.
  3. Choose an encoding. For garbled English, try “Western European Windows-1252” first, then “UTF-8”. For a Japanese, Chinese or Korean book, try that language’s option.
  4. Check the result in the preview, or in “Text check” at the bottom of the “Files” section, which shows the first 2,000 characters.
  5. If the other files in a series have the same problem, press “Use this encoding for the other files too”.

Sort out the encoding before you edit anything. Changing it re-reads the file from scratch, which discards edits, bold and italic, and chapters you set by hand for that file. The converter asks you to confirm first.

One English case is worth knowing about. A file in Windows-1252 whose only special characters are curly apostrophes is hard to detect, because those bytes also happen to form valid East Asian characters. Automatic detection can land on the wrong one and show “don뭪” instead of “don’t”. The file will be marked “Needs attention”, and choosing “Western European Windows-1252” fixes it right away.

What the error messages mean

The converter never quietly swaps unreadable bytes for placeholder symbols. If something doesn’t fit, it stops and tells you.

  • “This file can’t be read with the selected encoding. Please choose another one.” The file contains bytes that can’t exist in that encoding, so it’s the wrong choice. Try another, or go back to “Detect automatically”.
  • “The marker at the start of the file (BOM) doesn’t match the selected encoding.” The file declares its own encoding in its first few bytes, and your choice disagrees. Switch to “Detect automatically”.
  • “Found 3 control characters that can’t go into an ebook.” The number will vary. These invisible characters are usually a sign of the wrong encoding, so try a different one first. If the text already reads correctly, as with an old file that ends in a stray end-of-file mark, press “Remove and continue” to take out just those characters.

When changing the encoding doesn’t help

Sometimes the damage has been saved into the file. This happens when someone opens a UTF-8 file with the wrong encoding, sees ’, and saves it. The file is now valid UTF-8 that really does contain the characters â, € and ™. No encoding setting will bring the apostrophe back, because the correct bytes are gone. You can recognize this when the converter reports UTF-8 and the gibberish is still there.

There are two ways out.

  • Find a cleaner copy. If the text came from a website or a friend, a fresh download is often the quickest fix.
  • Use find and replace in a text editor. Replace ’ with ’, “ with “, … with … and é with é, and do the closing quote last, because it often appears as a bare †that would match the start of the others. Save the file as UTF-8 and add it to the converter again.

The black diamond � is different. It means a program already gave up on that character and replaced it, so the original can’t be recovered from this file. For a few of them, press “Edit” and retype the right character. For hundreds, look for another copy of the text.

Keeping it from happening again

Save your own writing as UTF-8, which nearly every current text editor offers in its save options. When you collect chapters from different places, check each one before merging them, since a single book can easily end up with files in two encodings. In the converter each file has its own encoding setting, so a mixed set can still become one clean book.

Open the converter