Home >Operation and Maintenance >Linux Operation and Maintenance >How to solve the problem of garbled characters when decompressing zip files under Linux?

How to solve the problem of garbled characters when decompressing zip files under Linux?

零下一度
零下一度Original
2017-07-18 14:02:102265browse

Since the encoding format is not specified in the zip format, the encoding in the zip files generated under Windows is GBK/GB2312, etc. Therefore, these zip files will have garbled characters when decompressed under Linux, because the default encoding under Linux is UTF8.

There is currently a method of unzip -O cp936 circulating on the Internet, but some unzips do not have the -O option.

The version I am using, the unzip 6.0 debian modified version, has this option

Due to encoding problems, the Chinese files in the zip file will appear garbled when decompressed under Linux

If you use archlinux, then use AUR to install unzip-natspec to solve this problem

At this time, use unzip xxx.zip to correctly decompress the file

Then operate in the file-roller archive manager, Chinese The name is still garbled. It is said that it is because file-roller preferentially uses p7zip

The problem is solved after deleting p7zip

However, I also want to be able to use the p7zip software package at the same time. Does anyone know how to solve this problem?

Download the code from here to study and find such logic

    /* give priority to 7z, unzip and zip that supports ZIP files better. */if ((strcmp (mime_type, "application/zip") == 0)|| (strcmp (mime_type, "application/x-cbz") == 0))
    {if (_g_program_is_available ("7z", check_command)) {return capabilities;
        }if (!_g_program_is_available ("unzip", check_command)) {
            capabilities |= FR_ARCHIVE_CAN_READ;
        }if (!_g_program_is_available ("zip", check_command)) {
            capabilities |= FR_ARCHIVE_CAN_WRITE;
        }return capabilities;
    }

This is hard-coded. It seems that there is no good way except to patch the code

Final solution, I found that there is also a similar software package p7zip-natspec in AUR

Installing this package should solve the problem perfectly, because I have solved the problem using the above method, so Won’t try this again

The above is the detailed content of How to solve the problem of garbled characters when decompressing zip files under 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