daraosn / node-zip

217 stars 38 forks source link

fixed garbled problem. #27

Open tooru opened 6 years ago

tooru commented 6 years ago

nodezip-cli.js has a garbled problem for multi-byte characters.

https://github.com/daraosn/node-zip/blob/a0d39629b6cbd84403f7b43c1f4e6c485478b93d/lib/nodezip-cli.js#L73

fs.readFileSync returns string content of filepath decoded as 'latin1' ('binary' is alias), then zip.file treats its string content as "utf-8" (see jszip v2.5.0 lib/objects.js).

To solve it, you remove the second argument 'binary'. Then it will be treated as binary.