unzip -O: Filename Encoding and Charset
unzip -O specifies the character set used to decode entry names that were stored in a non-UTF-8 encoding.
Archives built on Windows or older tools can store filenames in code pages like CP437 or Shift-JIS. -O tells unzip how to interpret them so names extract correctly.
What it does
unzip -O <charset> sets the source character set for decoding non-UTF-8 entry names, so they map correctly to the local encoding. -I sets the charset for ISO (non-OEM) names. These options exist in unzip builds compiled with the relevant Unicode/charset support.
Common usage
# decode names stored in the DOS code page 437
unzip -O CP437 archive.zip -d ./out
# decode Japanese Shift-JIS names
unzip -O sjis archive.zip -d ./outOptions
| Flag | What it does |
|---|---|
| -O <charset> | Charset for decoding OEM/non-UTF-8 names |
| -I <charset> | Charset for decoding ISO (non-OEM) names |
| -d <dir> | Target directory |
| -o | Overwrite without prompting |
In CI
When a partner-supplied archive extracts with mojibake or question marks in filenames, the names were stored in a non-UTF-8 code page. Try -O CP437 for DOS-era zips or the appropriate locale charset. Note that -O and -I are only present in unzip builds compiled with charset support, so a minimal runner unzip may lack them.
Common errors in CI
"-O: unknown option" means the unzip build was not compiled with charset support; the bundled unzip on some slim images lacks it. Garbled or replaced characters in filenames without -O indicate a non-UTF-8 source encoding. If the right charset still does not help, the archive may use the UTF-8 flag inconsistently, in which case a different extractor like 7-Zip can be more forgiving.