Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to solve the problem of decompressing garbled zip files under linux in CVM

Shulou Source: shulou.com Published: 2022-06-01 03:22:12 09月26日 Update

This article introduces how to solve the problem of decompressing garbled zip files under linux in CVM. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

CVM: solves the problem of decompressing garbled zip files under linux

Because the zip format does not specify the encoding format, the encoding in the zip files generated under Windows is GBK/GB2312 and so on, which leads to garbled problems when these zip files are decompressed under Linux, because the default encoding under Linux is UTF8.

Solution one

Use 7z to decompress.

Install p7zip and convmv

# fedora $su-c 'yum install p7zip convmv' # ubuntu $sudo apt-get install p7zip convmv

Execute the command to unzip

# decompress $7za x your-zip-file.zip # Recursive transcode $convmv-f GBK-t utf8-- notest-r.

Solution two

Files compressed on windows are compressed in Chinese by default. Because its encoding is not declared in the zip file, the unzip on linux is generally decompressed with the default encoding, and the Chinese file name will be garbled.

Although some people reported this as bug in 2005, info-zip 's official website did not include automatic identification codes in the plan, and they may not think this is a problem. Sun adopts the same way to deal with the N-year zip coding problem in java.

There are two ways to solve the problem:

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

Unzip-O CP936 xxx.zip (GBK, GB18030 is also possible)

Interestingly, there is no description of this option in unzip's manual, and unzip-help has a simple description of this parameter.

two。 In the environment variable, specify the unzip parameter, always display and extract the file in the specified character set

Add 2 lines to / etc/environment

UNZIP= "- O CP936" ZIPINFO= "- O CP936"

In this way, the Archive Manager (file-roller) of the Gnome desktop can normally use unzip to extract Chinese, but file-roller itself cannot set the encoding to be passed to unzip.

This is the end of how to solve the problem of decompressing garbled zip files under linux in the CVM. I hope the above content can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Tags: Files codes problems garbled servers services Chinese content parameters commands characters character sets methods solutions more formats solutions help good interesting Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information Xiaomi Redmi Apple