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.