Home > Backend Development > PHP Tutorial > Solve the problem of Chinese garbled characters in PclZip

Solve the problem of Chinese garbled characters in PclZip

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-08 09:28:24
Original
1473 people have browsed it

When using Pclzip, the file cannot be compressed/decompressed. After tracking the error message, I found that the file/directory cannot be opened, but the folder permissions are correct. After printing the file path, I found that it was garbled. The reason for this problem is that the file name encoding in the zip under Windows is gb2312, while PHP uses utf-8 encoding. The solution is to modify the pclzip.php class file:

Modify the compressed file part:

privAddFile method:

//$p_header['stored_filename'] = $p_filedescr['stored_filename'];

// Modify to the following line

$p_header['stored_filename'] = mb_convert_encoding( $p_filedescr['stored_filename'],'GB2312','UTF-8');

Modify the decompressed file part:

privExtractFile method:

$p_entry['filename'] = $p_path."/".$p_entry['filename'];

// Add the following line

$p_entry['filename' ] = mb_convert_encoding($p_entry['filename'], 'UTF-8', 'gb2312');

The above has introduced how to solve the problem of Chinese garbled characters in PclZip, including aspects of the problem. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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