Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何解决中文名称的乱码问题 #109

Open
luuman opened this issue Sep 5, 2020 · 12 comments
Open

如何解决中文名称的乱码问题 #109

luuman opened this issue Sep 5, 2020 · 12 comments

Comments

@luuman
Copy link

luuman commented Sep 5, 2020

No description provided.

@longnhp-agiletechvn
Copy link

The only solution: use English, that's all! Using Chinese in the wrong place will make you lower yourself.

@ShinChven
Copy link

const compressing = require('compressing');

const result = await compressing.zip.uncompress(file, unpackDir, {
zipFileNameEncoding: 'GBK'
});

@KevinAo22
Copy link

The only solution: use English, that's all! Using Chinese in the wrong place will make you lower yourself.

Where is the correct place for using Chinese?

@KevinAo22
Copy link

use JSZip to load data and write data into file system.

@longnhp-agiletechvn
Copy link

The only solution: use English, that's all! Using Chinese in the wrong place will make you lower yourself.

Where is the correct place for using Chinese?

LOL so why don't you answer him in Chinese but in English? Don't you find yourself ridiculous? My answer was in your comment.

@KevinAo22
Copy link

The only solution: use English, that's all! Using Chinese in the wrong place will make you lower yourself.

Where is the correct place for using Chinese?

LOL so why don't you answer him in Chinese but in English? Don't you find yourself ridiculous? My answer was in your comment.

I'm worried about your brain cannot handle Chinese. Pity you and help you understand.

@longnhp-agiletechvn
Copy link

longnhp-agiletechvn commented Apr 2, 2021

The only solution: use English, that's all! Using Chinese in the wrong place will make you lower yourself.

Where is the correct place for using Chinese?

LOL so why don't you answer him in Chinese but in English? Don't you find yourself ridiculous? My answer was in your comment.

I'm worried about your brain cannot handle Chinese. Pity you and help you understand.

Be superior in your own Chinese home, please! Nobody cares about your language, so you don't have to show others that you're a clown. Why do I need to handle Chinese? To be a clown like you? LMAO

@liujiusheng
Copy link

抄个代码还受到了歧视,我也换一个好啦

@hellobugme
Copy link

抄个代码还受到了歧视,我也换一个好啦

它又不是开发者,就一没脑子的傻卵罢了

@kirrs
Copy link

kirrs commented Dec 9, 2021

yauzl use cp437 encoding, you can find it here https://github.com/thejoshwolfe/yauzl/blob/master/index.js#L757

so you can do something like below

const extract = require("extract-zip");
const iconv = require('iconv-lite')

const cp437 = '\u0000☺☻♥♦♣♠•◘○◙♂♀♪♫☼►◄↕‼¶§▬↨↑↓→←∟↔▲▼ !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ '

function decodeCp437(str) {
  const buffArr = []
  for (const s of str) {
    buffArr.push(cp437.indexOf(s))
  }
  return Buffer.from(buffArr)
}

extract(
  'special encoding file name.zip',
  {
    dir: 'your unzip dir',
    onEntry: function (entry) {
     // decode
      entry.fileName = iconv.decode(decodeCp437(entry.fileName), 'special encoding')
    }
  }
)
  .then(() => { })

the solution is not so good because it did something opposite to yauzl
But you can use it as a temporary solution before extract-zip supports decodeStrings

@doornot
Copy link

doornot commented Dec 22, 2021

what "special encoding" should i set, tried 'GBK' is not working. @KirrsGool

@chirsz-ever
Copy link

ZIP format do not contain the encoding information of the file names, you need determine it by yourself or detect it (for Simplified Chinese it may be GBK).


ZIP 格式没有包含文件名的编码信息, 你需要自行决定或者探测解压时使用的编码, 简体中文一般是 GBK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants