Character encoding is the rule that turns letters and symbols into the numbers computers store. Open a text file and see é where you expected é? Or ’ instead of an apostrophe? That is an encoding mismatch. The two encodings you will meet are ASCII and UTF-8. Understanding utf-8 vs ascii is step one to fixing garbled characters and keeping text readable.

What ASCII and UTF-8 Are

ASCII is the oldest standard still in wide use. It defines a limited set of characters: English letters, digits, punctuation and control codes. Every character fits in a single byte. ASCII cannot represent accented letters, symbols like € or emoji.

UTF-8 is a newer encoding that can represent every character in the Unicode standard. It uses a variable number of bytes per character. The first 128 characters of UTF-8 are identical to ASCII. That means UTF-8 is backwards compatible with ASCII. A file containing only plain English text is valid in both encodings.

Why Text Files Show Weird Characters

When you open a plain .txt file, the program guesses which encoding the file was saved in. Plain .txt files do not record their encoding. A wrong guess means the bytes get interpreted as the wrong characters. This produces mojibake.

For example, the UTF-8 bytes for é read as Windows-1252 produce é. That is what is utf-8 being mistaken for a different encoding. The same problem hits curly quotes, em dashes and accented letters.

Common Garbled Patterns and Their Cause

Some garbled patterns are so common you can recognize the mismatch immediately.

  • é: The file is UTF-8 but opened as Windows-1252 or Latin-1. This is the most frequent garbled characters in text file scenario.
  • ’: A UTF-8 apostrophe or right single quote read as Windows-1252.
  • : A UTF-8 byte order mark (BOM) displayed as visible characters. This happens when the file starts with the three-byte BOM and the program does not recognize it.

See these patterns? Reopen the file with the correct encoding. Most text editors let you choose the encoding in the Open or Import dialog.

How to Fix Mojibake in a Text File

Step-by-Step Fix Using a Text Editor

  1. Open the file in a text editor that lets you choose the encoding. Notepad++ or any modern code editor works.
  2. If the file already shows garbled text, close it without saving.
  3. Reopen the file using the Open or Import command and select UTF-8 as the encoding. If that fails, try Windows-1252 or Latin-1.
  4. Once the text appears correct, save the file as UTF-8 (without BOM) to prevent future problems.

What About the BOM?

A byte order mark (BOM) is an optional marker at the start of a file. Some programs expect it. Others display it as stray characters. See  at the start of your file? The file was saved with a UTF-8 BOM. Remove it by saving as UTF-8 without BOM. Windows Notepad has saved new files as UTF-8 without a BOM by default since a recent Windows 10 update.

How Windows Notepad Handles Encoding

Windows Notepad is a common source of encoding confusion. New files are saved as UTF-8 without a BOM on recent Windows versions. But Notepad's Save As dialog has an Encoding dropdown where you can choose a different encoding. Open a file saved in a different encoding and Notepad may guess wrong.

To check the encoding of a file you are about to save, use the Save As dialog and look at the Encoding dropdown. For files you are opening, Notepad does not show an encoding choice. It guesses. If the result is garbled, switch to a different editor that lets you specify the encoding on open.

Preventing Encoding Problems

The easiest way to avoid mojibake? Always save text files as UTF-8. UTF-8 is the dominant encoding on the web and handles any character you type.

  • When you create a new text file, check that your editor is set to UTF-8 (without BOM unless you need it).
  • Sharing a plain text file? Tell the recipient which encoding you used. .txt files do not record their encoding, so the recipient must guess.
  • Receive a file that looks garbled? Try opening it with a different encoding before you edit. Do not save over the original until you are sure the encoding is correct.

For a simple, private text notepad in your browser that saves as you type and never uploads anything, try simpletext.ws. It handles encoding transparently so you can focus on writing.