decompress
decompress copied to clipboard
Unsupport Chinese Character
The zip file structure is:

After decompress, the structure is:

Note: file name is not correct.
Can you submit a failing test?
@Comee How to resolve it finally ?
I write a function to convert garble path to chinese. You can try it in your needed place.
decompress(path.join(__dirname, './七夕的副本.zip'), './中奖名单').then(files => {
files.forEach(file => console.log(garbleToChinese(file.path)));
});
function garbleToChinese(garble) {
if(typeof(garble) !== 'string') throw new Error('Not a string');
var cp437 = '\u0000☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ ';
var rs = garble.split('').reduce((pre, cur) => {
pre.push(cp437.split('').findIndex(v => v === cur));
return pre;
}, []);
return new Buffer(rs).toString('utf-8');
}
get result:
七夕的副本/
七夕的副本/.DS_Store
__MACOSX/
__MACOSX/七夕的副本/
__MACOSX/七夕的副本/._.DS_Store
七夕的副本/1.png
__MACOSX/七夕的副本/._1.png
七夕的副本/收集卡 /
七夕的副本/收集卡 /.DS_Store
@yozosann you saved my day
@yozosann In this way, only the correct characters can be output on the console. In fact, the extracted file name on the server is still garbled
import iconvLite from 'iconv-lite';
decompress(foo, {
map(file) {
return {
...file,
path: iconvLite.encode(file.path, 'cp437').toString(),
};
},
})
