简体   繁体   English

ZipArchive编码与日文文件名

[英]ZipArchive encoding with japanese file name

This is what I have done 这就是我所做的

$zip = new \ZipArchive;
    $zip->open('file.zip', \ZipArchive::CREATE | \ZIPARCHIVE::OVERWRITE);
    foreach ($files as $file) { 
        $zip->addFile( "images/ルフィエール.jpeg");   
    }

but inside the zip file it's not show properly, but it show like this : T¢+s¡És+Åpâ»péñpâ¦pé+pâ.jpeg 但在zip文件中它没有正确显示,但它显示如下:T¢+s¡s+Åpâ»péñpâ|pé+pâ.jpeg

Please help me!!! 请帮我!!!

Try using the code below, if it doesn't work try renaming the filename inside the zip to English, and see if it works then. 尝试使用下面的代码,如果它不起作用尝试将zip中的文件名重命名为英语,然后查看它是否有效。 If it does, then the issue is not from ZipArchive or zipping in general. 如果是,那么问题不是来自ZipArchive或一般的压缩。

$zip = new \ZipArchive;
$zip->open('file.zip', \ZipArchive::CREATE | \ZIPARCHIVE::OVERWRITE);
foreach ($files as $file) { 
// Hopefully the filename below is dynamic and you're not actually adding the same file over and over
    $file = "images/ルフィエール.jpeg";
    $content = file_get_contents($file); 
    //if it is possible for you, I would change the filename to english below as well if this doesn't work
    $file_added = $zip->addFromString( pathinfo($file,PATHINFO_BASENAME) , $content);
}
$zip->close();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM