Zip file while Chinese or Japanese Characters.

G

Guest

HELP!

I write a C# class which uses J# class
java.io.FileOutputStream,java.util.ZipInputStream and so on to do operations
on zip file.

For example:
When I add a file '1.txt' into 'hah.zip',everything goes well.
But if I add a file named '你好.txt',whose name contains Chinese or Japanese
characters,the zip file corrupts.

How cound I solve the problem.

Thx in advanced.
 
J

Jon Skeet [C# MVP]

Shrek said:
I write a C# class which uses J# class
java.io.FileOutputStream,java.util.ZipInputStream and so on to do operations
on zip file.

For example:
When I add a file '1.txt' into 'hah.zip',everything goes well.
But if I add a file named '??.txt',whose name contains Chinese or Japanese
characters,the zip file corrupts.

How cound I solve the problem.

I believe (although only on the basis of overhearing the conversations
of colleagues) that the zip format doesn't actually specify the
character encoding used for filenames, unfortunately. I think there's
only 8 bits per character though, which makes it impossible to reliably
get proper internationalisation :(
 
G

Guest

Thx,Jon.

But when I use WinZip or WinRar the add the file with Chinsese name into the
zip file,it works just fine.

How do they make it?

Thx.
 
J

Jon Skeet [C# MVP]

Shrek said:
But when I use WinZip or WinRar the add the file with Chinsese name into the
zip file,it works just fine.

How do they make it?

I suspect they're either using proprietary extensions to the zip file
format, or they're making a "best guess" at the encoding based on which
characters are in the filenames, unfortunately :(
 
J

Jacky Kwok

Shrek said:
HELP!

I write a C# class which uses J# class
java.io.FileOutputStream,java.util.ZipInputStream and so on to do operations
on zip file.

For example:
When I add a file '1.txt' into 'hah.zip',everything goes well.
But if I add a file named '你好.txt',whose name contains Chinese or Japanese
characters,the zip file corrupts.

How cound I solve the problem.

Thx in advanced.

Hi Shrek:

You may try the other zip library for .NET,
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx

I use it in my application. It can handle Chinese filename without problem.

However, you need to know that the zip file format does not use unicode
code character. All the filename, which are stored into the zip file,
are ANSI MBCS string.

Hence, there is a Unicode(in dotnet) to ANSI MBCS character convertion.
You Windows OS must set to use the Ansi codepage to this character set
to support the convertion by default.
For example, in an English Windows XP OS, I need to set the "Language
for non-Unicode programs" to Chinese(Taiwan) to support the Traditional
Chinese (Big5) filename.
 
G

Guest

Thx very muchï¼

Jacky Kwok said:
Hi Shrek:

You may try the other zip library for .NET,
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx

I use it in my application. It can handle Chinese filename without problem.

However, you need to know that the zip file format does not use unicode
code character. All the filename, which are stored into the zip file,
are ANSI MBCS string.

Hence, there is a Unicode(in dotnet) to ANSI MBCS character convertion.
You Windows OS must set to use the Ansi codepage to this character set
to support the convertion by default.
For example, in an English Windows XP OS, I need to set the "Language
for non-Unicode programs" to Chinese(Taiwan) to support the Traditional
Chinese (Big5) filename.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top