Home > Operation and Maintenance > Linux Operation and Maintenance > Solve the problem of Chinese garbled characters when decompressing unzip in Linux

Solve the problem of Chinese garbled characters when decompressing unzip in Linux

巴扎黑
Release: 2017-09-16 10:17:55
Original
2863 people have browsed it

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
Copy after login

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
Copy after login

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"
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template