This article mainly introduces relevant information on solutions to Chinese garbled characters when decompressing unzip in Linux. Here are two solutions. I hope this article can help everyone. Friends in need can refer to it
Solution to Chinese garbled characters when decompressing unzip in Linux
When we decompress a compressed package with a Chinese name such as "data.zip" in Linux, if we directly use the following command, Chinese garbled characters will appear.
unzip 资料.zip
The main reason is because unzip will convert the encoding to its internal default encoding when decompressing, and the default encoding does not support Chinese CP936 encoding at all. Therefore, we need to explicitly specify the encoding to be used when decompressing.
Currently, the following two methods can be used to solve the problem
Method one is to directly specify the encoding format when decompressing
#指定GBK GB18030编码也是可以的 unzip -O CP936 资料.zip
Method 2 Configure environment variables and specify unzip parameters
In environment variables, specify unzip parameters and always display and decompress files in the specified character set
For example, you need to add 2 lines to /etc/environment:
UNZIP="-O CP936" ZIPINFO="-O CP936"
The above is the detailed content of Solve the problem of Chinese garbled characters when decompressing unzip in Linux. For more information, please follow other related articles on the PHP Chinese website!