How to extract zip file which contains filenames with SHIFT_JIS encoding in Ubuntu
If a zip file contains the filenames which are Japanese, the encoding normally is SHIFT_JIS especially Windows. To extract the files, normal “unzip” will not work. 7z is a good solution.
The following commands are done in terminal. Firstly, we need to change the LANG environment variable, because the default LANG is normally UTF-8. Since the filenames are SHIFT_JIS, which is not UTF-8, we need to change it.
LANG=ja_JP # Don't use UTF-8
Then,
7z e jp.zip #extract the files and preserve the encoding
As a result, a list of unreadable files are extracted. Then use convmv command to convert the filenames. Assuming all the files are in a same folder.
convmv --notest -f shift-jis -t utf8 *.* #convert all the filename to UTF8
If we don’t know the character encoding for the filenames, we can also use the iconv to check the encoding before extract them,
env LANG=ja_JP 7z l jp.zip | iconv -f SHIFT-JIS -t UTF8
Update (2011-05-16):
The easiest way is using the 7-zip through Wine and installing all the required fonts through winetricks.
Please, fix you article:
“7z a jp.zip” this don’t extract. Use the command “7z e” to extract.
Thanks, I didn’t notice that.