Skip to content
Aback ZIP

Deep dives · 10 min read · Updated

Unicode File Names in ZIP Archives

Why names like résumé.pdf or 文件.pdf turn into gibberish, what the UTF-8 flag actually does, and how to repair the encoding without changing any file contents.

A ZIP stores file names as bytes, not as text. A flag bit tells readers to interpret those bytes as UTF-8; older Windows tools instead wrote the machine's local code page. When the flag and the bytes disagree, names appear as mojibake. The file contents are almost always fine.

Names are bytes plus a flag

In the ZIP format, a file name is a counted sequence of bytes in the local header and again in the central directory. The format originally assumed a DOS or Windows code page, because that is what its authors used. Later, a general-purpose flag bit was reserved to mean 'these name bytes are UTF-8'. Readers that honour the bit decode the name as UTF-8; readers that do not will guess a local code page and display something else.

Nothing about this changes the stored file data. A broken name is a problem with the label on the box, not with the contents of the box. That distinction is the reason a name repair can leave every file byte-for-byte identical. The byte layout is described more fully in Inside a ZIP file, byte by byte, and the authoritative definition is in PKWARE's APPNOTE.

How mojibake happens

Mojibake is the result of decoding bytes with the wrong character encoding. If a writer puts UTF-8 bytes into the name field without setting the flag, a reader on a Western Windows system may interpret each byte as CP1252 and show résumé.pdf instead of résumé.pdf. If a writer uses Shift_JIS, GBK, Big5, EUC-KR or CP866 and the reader assumes something else, the result is a string of unrelated characters or box symbols.

Correct name:   résumé.pdf
UTF-8 bytes:    72 C3 A9 73 75 6D C3 A9 2E 70 64 66
Read as CP1252: résumé.pdf

Correct name:   文件.pdf
UTF-8 bytes:    E6 96 87 E4 BB B6 2E 70 64 66
Read as Latin-1: 文件.pdf

The characters are not random. Each was produced by a consistent but wrong mapping, which is why a repair tool can often infer the original encoding and reverse it. The catch is inference: if a name uses only characters that look plausible in several encodings, the tool may guess wrong, so always read the preview before accepting a fix.

Repairing names without touching contents

  1. Open the archive in ZIP Viewer and look at the entry names. If they are garbled but the file sizes and structure look normal, encoding is the likely problem.
  2. Use Fix ZIP Filenames and read the before-and-after list. The tool detects common code pages including Shift_JIS, GBK, Big5, EUC-KR and CP866.
  3. If a name still looks wrong, try another detected encoding. Some archives contain names written in more than one code page.
  4. Download the rewritten archive and open it in the application the recipient will use, to confirm the names survive there too.

The rewritten archive keeps the original file contents. Only the name bytes and the flag that describes them are changed. That is what makes a repair safe to verify: if a checksum of an extracted file matches the original, the data was untouched. The why ZIP file names are garbled guide covers the same problem from the user's point of view.

Double-encoded names are harder. If someone has already 'fixed' a garbled name by saving it as UTF-8 text, the original bytes are gone and no tool can reliably reconstruct them. Keep an unmodified copy of the archive before experimenting.

Creating archives that keep names intact

The easiest fix is to write correct names in the first place. Create ZIP stores names as UTF-8 and sets the flag, so names such as résumé.pdf, नमस्ते.pdf, 文件.pdf, 日本語.txt, العربية.txt and emoji 📁.txt survive in modern readers. The how-to guide shows the full workflow, including folder structure and empty files.

  • Avoid characters that Windows does not permit in file names: \ / : * ? " < > |, and names ending in a dot or a space.
  • Keep full paths reasonably short. Some Windows tools still struggle with paths beyond the traditional 260-character limit.
  • Unicode text can be written in more than one equivalent form. A name composed of a letter plus an accent mark may look identical to a precomposed letter but use different bytes, which can confuse duplicate detection.
  • Case-insensitive file systems cannot hold Report.pdf and report.pdf as two different files. A writer has to rename one of them.

Common symptoms and their causes

What you seeLikely causeWhat to do
résumé.pdfUTF-8 bytes read as a Western code pageSet the UTF-8 flag when writing, or re-encode the name
Boxes or unrelated Asian charactersShift_JIS, GBK, Big5 or EUC-KR name read as another encodingDetect and rewrite the names with Fix ZIP Filenames
Names correct on one machine, wrong on anotherReader ignoring the UTF-8 flagUse a modern archive application on the second machine
Two entries with almost the same nameUnicode normalisation or case differencesInspect both entries before deleting either

If the archive was made by a Japanese or Chinese Windows program years ago, assume a local code page rather than UTF-8. That is the case the repair tool is designed for. If the archive was made recently by a modern application, a garbled name may instead point to a bug in the reader.

A note on safety

File names are untrusted strings. A name containing ../ is an instruction in a path, not just a label, and an extractor has to refuse to write outside its target folder. A name can also include control characters or very long strings that break a table layout. Aback ZIP treats names as text to display and sanitises paths before extraction; it does not execute archive contents. If an archive's names look deliberately strange, check it with ZIP Safety Check before extracting.

Testing names before you send

A name that looks right in the tool that created the archive is not necessarily right everywhere. If the archive will cross platforms, open it in at least one application other than the one you used to build it.

  1. Include one name with an accented Latin character, one with a non-Latin script and one with an emoji in your test archive.
  2. Extract that test archive on the recipient's platform, or ask them to read back the names they see.
  3. If the names are garbled, check whether the creator set the UTF-8 flag before assuming the reader is at fault.
  4. If the names are correct but sorting looks strange, investigate Unicode normalisation rather than the encoding flag.
  5. Keep the test archive small; the point is to check labels, not transfer performance.

A five-minute check with a throwaway archive is cheaper than rebuilding a large one after a recipient reports that every file name is unreadable.

Tools for this

Frequently asked questions

The names were written in a local code page such as GBK, and the reader is decoding them as UTF-8 or another code page. The file contents are unaffected; only the name bytes need rewriting.

More posts