CSV

Why Excel Shows Garbled Characters in UTF-8 CSV Files (and How UTF-8 BOM Fixes It)

Compare the bytes behind a garbled name, test Excel’s UTF-8 import path, and choose between a BOM-prefixed CSV and a text-cell workbook.

A supplier sends a CSV containing “Málaga”. A text editor shows the city correctly, while double-clicking the same attachment in Excel produces “Málaga”. Before replacing characters, import the untouched attachment with the character set explicitly set to UTF-8. If the name now reads correctly, the producer has already supplied the right bytes. The difference lies in how the two opening paths chose to interpret them. Saving the misread sheet over the attachment would turn a reversible display problem into a changed data file.

Trace the two bytes behind the wrong name

UTF-8 encodes a basic ASCII letter in one byte and the accented letter á in two. A legacy single-byte reader treats each byte of that pair as its own character. The resulting pair of visible characters is a useful clue because the same error often repeats wherever the accented letter appears. Test several real values. All-ASCII column headings such as “city” or “id” survive either interpretation and are poor evidence that the import worked.

Text                           Málaga
UTF-8 bytes                    4D C3 A1 6C 61 67 61
Read those bytes as CP1252     Málaga
UTF-8 file with a BOM          EF BB BF 4D C3 A1 6C 61 67 61
Legacy CP1252 source instead   4D E1 6C 61 67 61

The optional UTF-8 signature is the three bytes EF BB BF at the very beginning of the file. UTF-8 has no alternate byte order to choose between. Here the mark is a recognizable signature for readers, including Excel opening paths that use it to identify the encoding. It belongs before the first field, just once. Adding those bytes in front of a legacy E1 does not turn that byte into UTF-8. A legacy source must first be decoded correctly, then encoded to UTF-8.

Compare three ways of opening the same export

HandoffWhat it controlsWhat still needs checking
Text/CSV import with UTF-8 selectedEncoding on this importDelimiter and inferred column types
UTF-8 CSV with a BOMA recognizable encoding hint in the fileRecipient's parser and first header name
XLSX with text cellsCell boundaries and string typesNumeric columns for calculations

Test the original with Excel's text or CSV import command in a blank workbook. Menu names vary across versions. Look for a file-origin or encoding control and select UTF-8, sometimes shown as code page 65001. Choose the actual field separator independently. Review a city with an accent, a currency symbol and one non-Latin name if present. Only load the preview after the characters and the number of columns both make sense. This exercise tells you what the source contains before changing how it will be delivered.

For a repeatable direct-open handoff, load the original CSV file into the on-device CSV encoding tool. Choose the source encoding that reproduces the known names. Inspect the delimiter and preview, then download the UTF-8 CSV with BOM. Open the downloaded copy using the recipient's usual method, including double-click if that is their normal workflow. A test performed only through a carefully configured import wizard cannot establish that direct opening works on the same installation.

Check the header as carefully as the data

Hex strip with EF BB BF before the bytes for the CSV header id,n.
The signature occupies the first three bytes of the file. The CSV header begins immediately afterward.

A recipient might feed the same file to a billing script that expects the first header to be exactly “customer_id”. A reader that decodes the signature as a literal U+FEFF character produces a first header that looks correct on screen but compares unequal to the expected string. Inspect the code points of the first header when a dictionary lookup fails only on the first column. A BOM-aware UTF-8 reader removes the leading signature when decoding, keeping the rest of the text intact.

If the first header starts with “”, the signature itself was likely decoded with a Western single-byte encoding. Reopen the original with the correct character set. Deleting those visible letters after a bad import leaves every other affected value in the same wrong interpretation. When delivering to both a person and a machine, document the encoding contract for each. A machine interface that explicitly requires plain UTF-8 can receive its agreed export while Excel users receive a BOM-prefixed copy or an XLSX workbook.

Separate characters, columns and cell types

If “Málaga” now reads correctly but row one occupies a single cell, you have resolved the character problem. Inspect the delimiter next. A semicolon-separated file and a comma-separated file can both be valid UTF-8 with an identical signature. If a postal code changes from 00123 to 123, Excel interpreted the decoded field as a number. Mark identifier columns as text before loading, or use the local CSV to XLSX tool to write all input cells as text in a workbook.

For an acceptance sample, use a row that combines a non-ASCII name, a padded identifier and a quoted address containing a comma. Compare the resulting three cell values individually. Check a later row as well, especially after a quoted multiline note. Matching the visible first row alone misses cases where a closing quote is absent much farther down. If a colleague will sum an amount column in a text-cell workbook, convert only that column after confirming decimal and thousands separators.

For an automated reconciliation, compare decoded field values instead of comparing whole-file hashes. Adding three signature bytes necessarily changes the hash, and a writer may normalize line endings or quotes while preserving the same records. Read both inputs using their declared character sets and compare logical rows with a CSV parser. A discrepancy confined to the first header suggests signature handling. A discrepancy in every accented name points back to decoding.

Limitations of adding a BOM

A BOM cannot recover bytes overwritten with literal question marks, restore the original letters behind a saved replacement character, or resolve a mixture of encodings across concatenated exports. Look for the earliest unmodified attachment or ask the producer to regenerate the file from its source table. When combining several UTF-8 files, decode each separately and combine records. Concatenating their raw bytes may insert another signature halfway through a field or repeat headers as ordinary data rows.

Both linked conversion tools work on-device. Keep the original for checking and give the corrected copy a distinct filename. For a recurring export, specify the exact encoding, whether the signature is present, the field separator, quoting rules and which columns carry identifiers. Ask the recipient to send back one problematic row from the delivered copy if the issue recurs. That gives you a specific field and opening method to reproduce, instead of a screenshot that cannot distinguish the underlying bytes.

References & further reading

Tools for this guide