banner
biuaxia

biuaxia

"万物皆有裂痕,那是光进来的地方。"
github
bilibili
tg_channel

Fixing ZipUtil-unzip-invalid-CEN-header-bad-entry-name

title: Fixing ZipUtil.unzip invalid CEN header (bad entry name)
date: 2021-08-31 12:00:54
toc: true
category:

  • Tips
    tags:
  • Tips
  • Fixing
  • Error
  • 7-zip

When there are Chinese file names in a zip file compressed with 7-zip, the Chinese file names become garbled when extracted on other platforms. After searching online, I found that when compressing zip files with 7-zip, you can use the parameter "cu=on" to force the file names to be encoded in UTF-8, which will result in normal extraction on other platforms.

The following image shows the use of the "cu=on" parameter when compressing zip files with 7-zip and the file name is in Chinese, forcing the Chinese file name to be encoded in UTF-8.

d4a3c47d6a7d7b8b677741dcdbb7a435.jpg

via. https://bbs.360.cn/thread-6400121-1-1.html

7-zip Parameters#

Compression#

Parameter                     Default     Description
x=[0 | 1 | 3 | 5 | 7 | 9 ]    5           Sets level of compression.
m={MethodID}                  Deflate     Sets a method: Copy, Deflate, Deflate64, BZip2, LZMA, PPMd.
fb={NumFastBytes}             32          Sets number of Fast Bytes for Deflate encoder.
pass={NumPasses}              1           Sets number of Passes for Deflate encoder.
d={Size}[b|k|m]               900000      Sets Dictionary size for BZip2
mem={Size}[b|k|m]             24          Sets size of used memory for PPMd.
o={Size}                      8           Sets model order for PPMd.
mt=[off | on | {N}]           on          Sets multithreading mode.
em={EncryptionMethodID}       ZipCrypto   Sets a encryption method: ZipCrypto, AES128, AES192, AES256
tc=[off | on]                 off         Stores NTFS timestamps for files: Modification time, Creation time, Last access time.
cl=[off | on]                 off         7-Zip always uses local code page for file names.
cu=[off | on]                 off         7-Zip uses UTF-8 for file names that contain non-ASCII symbols.

By default (if cl and cu switches are not specified), 7-Zip only uses UTF-8 encoding for file names that contain symbols not supported by the local code page.

x = [0 | 1 | 3 | 5 | 7 | 9]#

Sets the compression level. x = 0 means copy mode (no compression).

Deflate/Deflate64 settings:

Level NumFastBytes    NumPasses   Description
1     32              1           Fastest
3                                 Fast
5                                 Normal
7     64              3           Maximum
9     128             10          Ultra

x = 1 and x = 3, Deflate method is set to fast mode for compression.

BZip2 settings:

Level Dictionary  NumPasses   Description
1     100000      1           Fastest
3     500000                  Fast
5     900000                  Normal
7                 2           Maximum
9                 7           Ultra

fb = {} word size#

Sets the number of fast bytes for the Deflate/Deflate64 encoder. It can be in the range of 3 to 258 (257 for Deflate64). Generally, larger numbers provide better compression ratio and slower compression process. Larger fast byte parameter can significantly improve compression ratio for files that contain long identical byte sequences.

pass = {}#

Sets the number of passes for the Deflate encoder. For Deflate, it can be between 1 and 15, and for BZip2, it can be between 1 and 10. Generally, larger numbers provide better compression ratio and slower compression process.

d = {} size and [b | k | m]#

Sets the dictionary size for BZip2. You must specify the size in bytes, kilobytes, or megabytes. The maximum value for dictionary size is 900000b. If no symbol from the set [b | k | m] is specified, the dictionary size will be calculated as DictionarySize = 2 ^ Size bytes.

mem = {} size and [b | k | m]#

Sets the memory size for PPMd. You must specify the size in bytes, kilobytes, or megabytes. The maximum value is 256 MB = 2 ^ 28 bytes. The default value is 24 (16MB). If no symbol from the set [b | k | m] is specified, the memory size will be calculated as (2 ^ Size) bytes. PPMd uses the same amount of memory for compression and decompression.

o = {} size#

Sets the model order for PPMd. The size must be in the range of [2,16]. The default value is 8.

mt = [off | on | {N}]#

Sets the multithreading mode. If you have a multiprocessor or multicore system, you can use this switch to improve speed. This option only affects compression (using any method) and decompression of BZip2 streams. Each thread in multithreading mode uses 32 MB of RAM for buffering. If {N} is specified, 7-Zip will attempt to use N threads.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.