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!