文件名中带有重音字符的PHP ZipArchive

文件名中带有重音字符的PHP ZipArchive,php,windows-7,ziparchive,non-ascii-characters,Php,Windows 7,Ziparchive,Non Ascii Characters,我正在UNIX系统上使用PHP5.3.10创建ZIP存档,ZIP版本为1.12.5,Libzip版本为0.11.2: <?php $zip = new ZipArchive(); $test_zip = "./test.zip"; if ($zip->open($test_zip, ZIPARCHIVE::CREATE)===TRUE) { $zip->addFromString("Liste client à exporter.txt","Content line 1

我正在UNIX系统上使用PHP5.3.10创建ZIP存档,ZIP版本为1.12.5,Libzip版本为0.11.2:

<?php
$zip = new ZipArchive();
$test_zip = "./test.zip";
if ($zip->open($test_zip, ZIPARCHIVE::CREATE)===TRUE)
{
    $zip->addFromString("Liste client à exporter.txt","Content line 1\nContent line 2\n");
    $zip->close();

    if(file_exists($test_zip))
    {
        header ("Content-Type: application/octet-stream");
        header ("Accept-Ranges: bytes");
        header ("Content-Length: ".filesize($test_zip));
        header ("Content-Disposition: attachment; filename=\"test.zip\"");
        header ("Cache-Control: max-age=60");
        readfile($test_zip);
        unlink ($test_zip);
    }
}
?>
当我在Windows 7上使用内部ZIP打开生成的ZIP文件test.ZIP时,我会在归档文件中看到类似Liste client+107a exporter.txt的文件,而不是Liste clientáexporter.txt。 但如果用7z打开它,文件名是正确的,带有重音。 PHP文件具有UTF-8编码

解决 问题出现在Windows 7修补程序KB2704299中


我也有同样的问题,我是法国人,所以口音的问题我知道

为了避免这个问题,我使用了一个外部zip命令

对于Linux:

exec("cd \"".$the_directory_you want_to_zip."\" && zip -0 -r \"".$path_zip."\" .");

目前不确定Windows 10和Php7的当前状态,但以防有人对Windows上的zip重音仍有问题

压缩时需要将文件名转换为IBM850,从压缩中提取时需要将文件名转换为UTF8、ISO-8859-1、CP1252

//拉链 $relativePath=iconv'UTF-8','IBM850',$relativePath; $zip->addFile$filePath,$relativePath; //提取 $relativePath=iconv'IBM850','UTF-8',$zip->getNameIndex$i; $zip->rename索引$i,$relativePath; $zip->提取到$destination,$relativePath;
以解密格式打开的zip文件?不明白你的意思。下载后它会自动打开。双击zip文件也会产生同样的效果。确切的问题是,当使用内部Windows arhciver打开存档文件时,它会显示没有重音符号的文件名。这没有帮助。同样的效果:内部窗口的升级效果相同+a。使用7z名称是正确的。