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.

Tags:

About allencch

A programmer, a software engineer, a philosopher, a Catholic.

2 Responses to “How to extract zip file which contains filenames with SHIFT_JIS encoding in Ubuntu”

  1. Marco says :

    Please, fix you article:

    “7z a jp.zip” this don’t extract. Use the command “7z e” to extract.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 130 other followers