Stuk / jszip

Create, read and edit .zip files with Javascript
https://stuk.github.io/jszip/
Other
9.77k stars 1.3k forks source link

why I can't use it with chinese file name #226

Open kooksee opened 9 years ago

kooksee commented 9 years ago

I want to zip kinds of files,but I try many times I just can't zip chinese name file,such as zip.file('顶顶顶顶', fs.readFileSync(path)); .Can you help me ? Thank you very much!

dduponchel commented 9 years ago

What do you use to check the result ? Windows 7's explorer ?

JSZip uses UTF8 to encode/decode the file name inside a zip file (see also #211 for other encodings). Unfortunately, the compressed folders feature on Windows (up to and including Windows 7) uses the locale of the machine which will open the file (even with an unicode flag). Other file archivers that handle UTF8 will be fine (I just tested your example on my machine). If you use #211 to use a different encoding for the file name, you might have issues with other tools like 7zip which only understand UTF8. This issue is not specific to JSZip, others have this issue too (1, 2, 3).

We need to add this in the documentation, this question is asked regularly.