adm-zip icon indicating copy to clipboard operation
adm-zip copied to clipboard

filename or path contains chinese characters

Open 183181731 opened this issue 5 years ago • 3 comments

when filename or path contains chinese characters,the output zip file file name issue Code: var dic = /my dic path/ var zip = /my zip path/ var zip = new AdmZip(); zip.addLocalFolder(dic); zip.writeZip(zip); image

183181731 avatar Nov 24 '20 04:11 183181731

Can you try this.

#!/usr/bin/env node

var AdmZip = require('adm-zip');
var fpp = require('path');

function packer(folder, filepath){
    var zip = new AdmZip();

    zip.addLocalFolder(fpp.join(__dirname,folder));

    // update file headers
    zip.getEntries().forEach(entry => {
        entry.header.flags |= 0x0800;                                          // Set bit 11 - APP Note 4.4.4 Language encoding flag (EFS)
    });

    // save file (we generate our content again)
    zip.writeZip(fpp.join(__dirname,filepath));

}

packer('./packme','./測試文件.zip');

It seems to working:

Screenshot from 2020-11-24 11-08-58

5saviahv avatar Nov 24 '20 09:11 5saviahv

@5saviahv thanks!! it can work for me

183181731 avatar Nov 25 '20 11:11 183181731

Thanks! It works.

For the convenience of future people, I put my code up:

// pre
const zip = new AdmZip()
zip.addLocalFolder("dist/")
zip.writeZip(`dist/macao-${serverName}-${getTimeTag()}.zip`)
// after
const zip = new AdmZip()
zip.addLocalFolder("dist/")
zip.getEntries().forEach((entry) => {
  entry.header.flags |= 0x0800
})
zip.writeZip(`dist/macao-${serverName}-${getTimeTag()}.zip`)

wewindy avatar Jun 11 '21 07:06 wewindy

It should be default behaviour for now

5saviahv avatar Jun 24 '24 11:06 5saviahv