Fix garbled characters in a CSV
Understand UTF-8, the byte order mark, and what an encoding change can recover.
Quick answer. Return to the original bytes and choose the encoding used by the exporter. A UTF-8 BOM may help Excel recognize UTF-8, but adding a BOM cannot reverse text that was already decoded incorrectly and saved.
Try a file with a known result
Original synthetic teaching data; no customer records. Download the small sample, then load it into the matching tool. Your own files remain in your browser.
Settings for this example
These two files contain the same synthetic records in different encodings. Use the file picker: pasting decoded text does not test byte decoding. Load the Windows-1252 file, select Windows-1252 explicitly, Comma and a header, then preview. Compare with the UTF-8 BOM file in Auto mode.
Expected results to compare
- Auto mode rejects the Windows-1252 sample as invalid UTF-8; this is an expected protective error, not proof that the file is corrupt.
- With Windows-1252 selected, the result has 2 data records and 2 columns, with Café mug and Crème brûlée intact.
- The UTF-8 BOM sample produces the same field values in Auto mode. Export UTF-8 with BOM and compare accented characters in the receiving application.
Choose Windows-1252 only for this known sample or a source that actually uses it. A visually plausible preview is not universal encoding detection, and replacement characters in a saved source may be irreversible.
Open the matching tool →Separate bytes from characters
A text file stores bytes. An encoding tells a reader how those bytes represent characters. Choosing the wrong encoding can make an accented name or non-Latin text appear garbled even when the original bytes are still intact.
id,name 00127,Café mug
This teaching example contains é. Compare that character with your source, rather than deciding an encoding is correct merely because the first row of ordinary ASCII letters looks right.
What auto mode actually does
TableMender’s auto mode recognizes a UTF-16 byte order mark when present. Otherwise it attempts a strict UTF-8 decode. If the bytes are not valid UTF-8, it shows an error instead of silently replacing them. This is a check of a proposed encoding, not universal detection of every legacy format.
Try the encoding used by the exporting system
- Keep an unchanged copy of the original export.
- Choose the file in CSV check & repair.
- If auto mode fails, select the original encoding if you know it. This version offers UTF-8, UTF-16 little/big-endian, Windows-1252, Shift JIS and GB18030.
- Preview and compare meaningful characters in several records with the exporting system.
- Download UTF-8 output only when the decoded values are correct.
When a UTF-8 byte order mark helps
A byte order mark at the beginning of a UTF-8 file can help an application recognize its encoding. Microsoft specifically describes opening UTF-8 CSV normally in Excel when the file includes a BOM, and provides import alternatives. Some other systems prefer a file without it. TableMender lets you choose rather than making one option mandatory.
Know what cannot be recovered
If a previous program already saved replacement characters such as �, changing the encoding will not reconstruct the missing text. Likewise, a file can be valid UTF-8 while containing text that was damaged earlier. The tool flags replacement characters as a reason to check the original, not as proof that it can repair them.
Work from the original bytes. Encoding conversion is not a substitute for checking whether the exported values match the source system.
After exporting
Import the new file with UTF-8 selected when your receiving application offers that choice. Check record counts, names and identifiers. Encoding fixes do not set spreadsheet column types; if you also need to preserve leading zeros, use the text-preserving XLSX converter.
Edge cases and boundary cases
Auto mode that rejects a file as invalid UTF-8 is a protective stop, not proof the bytes are corrupt. Select the exporter’s encoding when you know it. A visually plausible ASCII header can hide wrong bytes in later accented rows—always compare a non-ASCII field, not only the first column of codes.
Valid UTF-8 that already contains mojibake (for example Café) will not become Café by choosing Windows-1252 again. That case is a saved wrong character sequence; see Mojibake and BOM and prefer a re-export when the original bytes are gone.
A UTF-8 BOM helps some Excel builds recognize UTF-8 and confuses some other pipelines. Export with or without a BOM deliberately after the decoded preview is correct. Adding a BOM cannot repair replacement characters (�) already stored in the file.
Mixed encodings in one download, or a binary preamble before the header, are outside a single encoding menu. Strip only a preamble you can name as metadata, then decode. When in doubt, use Repair versus re-export to decide whether local decoding is enough.
Shift JIS and GB18030 are offered for known sources that use them. Do not cycle encodings until the preview “looks nicer”; compare against the exporting application’s spelling of the same record.
Worked example: Windows-1252 versus UTF-8
Download encoding-windows-1252.csv and encoding-utf8-bom.csv. They hold the same two teaching rows — Café mug and Crème brûlée — in different bytes. Use the file picker. Pasted text is already decoded by the browser and cannot test this.
Auto mode on the Windows-1252 file fails with a “not valid utf-8” error. That is a protective stop. Select Windows-1252, Comma and a header, then Preview. The names should match the UTF-8 BOM file opened in Auto. Export UTF-8 (with or without a BOM) only after that comparison.
Step-by-step troubleshooting
- Auto says the file is not valid UTF-8. Select the exporter encoding. Windows-1252 is common for Western European CSV from older Excel. The error names the encoding that failed, not a corrupt disk.
- Preview shows �. Replacement characters are already stored. Encoding cannot reconstruct them. Re-export. Preflight reports U+FFFD cells when they appear.
- Preview shows Café and Auto succeeded. The file is valid UTF-8 containing mojibake. Another encoding pass will not restore Café. See Mojibake and BOM.
- ASCII codes look fine, names later in the file do not. Always compare a non-ASCII field. The first column of product codes is a weak acceptance test.
- Excel still garbles the UTF-8 export. Turn on Add UTF-8 BOM for Excel-bound CSV, or use the XLSX converter. Some pipelines must stay BOM-less; choose deliberately.
FAQ grounded in CSV check & repair
Does Auto detect Windows-1252? No. Auto only switches on a UTF-16 BOM; otherwise it tries strict UTF-8. You choose Windows-1252, Shift JIS or GB18030 when you know the source.
Can I paste a garbled name to test encoding? No. Paste is already characters. Choose the original file so the tool can decode bytes.
Will a BOM fix mojibake? No. A BOM is a signature at the start of the file. It does not rewrite Café into Café.
The local preflight summary after Preview repeats the encoding label and BOM signature, with a What to do line. Download that summary as a CSV if you need a record of the checks. When the check is not clear, the summary links here. Matching tool: CSV check & repair.
Before and after: the same Windows-1252 bytes
Download encoding-windows-1252.csv and use the file picker in CSV check & repair. Pasting text does not test byte decoding. The file is the same teaching rows as encoding-utf8-bom.csv, stored as Windows-1252 instead of UTF-8.
| Setting | What you should see |
|---|---|
| Auto (strict UTF-8 unless a UTF-16 BOM is present) | Error: the file is not valid UTF-8. That is a protective stop, not proof the file is corrupt |
| Windows-1252, Comma, header on | 2 data records, 2 columns. Names are Café mug and Crème brûlée |
| UTF-8 BOM sample, Auto | The same field values. Export UTF-8 with BOM only if the next Excel open needs the signature |
Compare those letters with the exporting system. A plausible ASCII header is not a certificate. If the preview shows Café and Auto succeeded, the file is already valid UTF-8 mojibake — see Mojibake and BOM. Another encoding pass will not restore Café. After a good decode, keep identifier columns as text in CSV to Excel.
Honest limits
This tool decodes with the encoding you select. It does not detect every legacy code page, and it will not silently replace invalid bytes. Windows-1252 is correct for this sample and for a source that actually used it; it is the wrong guess for Shift JIS or GB18030 bytes. A replacement character (�) means those bytes were already lost. Adding a BOM cannot reconstruct them. Choose a fresh export, then decide repair versus re-export if zeros or long ids were rewritten in the same file.
Decode the original bytes once, compare a non-ASCII field, and stop. A second encoding pass on already-saved wrong letters makes a new file, not the old names.
Sources:
Examples are original teaching data. Tool-specific behavior describes this version of TableMender; software interfaces can vary by version.