Home  >  Article  >  Operation and Maintenance  >  Solution to garbled characters in zip decompression in Linux

Solution to garbled characters in zip decompression in Linux

尚
Original
2019-12-26 11:23:233148browse

Solution to garbled characters in zip decompression in Linux

The files compressed on Windows use the system default encoding Chinese to compress the files. Since the encoding is not declared in the zip file, unzip on Linux is generally decompressed with the default encoding, and the Chinese file name will be garbled.

There are 2 ways to solve the problem:

1. Decompress through the unzip line command and specify the character set

unzip -O CP936 xxx.zip (用GBK, GB18030也可以)

Interestingly, there is no such thing in the unzip manual Description of options, unzip --help has a simple description of this parameter.

2. In the environment variable, specify the unzip parameter, and always display and decompress the file /etc/environment in the specified character set. Add 2 lines UNZIP="-O CP936" ZIPINFO="- O CP936"

In this way, the archive file manager (file-roller) of the Gnome desktop can use unzip to decompress Chinese normally, but the file-roller itself cannot set the encoding and pass it to unzip.
Adopted the first method above and the problem was solved.

Recommended related articles and tutorials: linux tutorial

The above is the detailed content of Solution to garbled characters in zip decompression in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn