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.
[code language=“bash”]LANG=ja_JP # Don’t use UTF-8, use “export” if needed[/code]
Then, [code language=“bash”]7z x jp.zip #extract the files and preserve the encoding[/code]
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.
[code language=“bash”]convmv –notest -f shift-jis -t utf8 *.* #convert all the filename to UTF8[/code]
If we don’t know the character encoding for the filenames, we can also use the iconv to check the encoding before extract them,
[code language=“bash”]env LANG=ja_JP 7z l jp.zip | iconv -f SHIFT-JIS -t UTF8[/code]
Update (2011-05-16): The easiest way is using the 7-zip through Wine and installing all the required fonts through winetricks.