ZipArchive使用哪些编码在创建的存档中存储文件名? [英] What encoding does ZipArchive use to store file names inside the created archive?

查看:116
本文介绍了ZipArchive使用哪些编码在创建的存档中存储文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用php ZipArchive类来生成zip存档。我使用addFile方法的第二个参数来设置存档中文件的名称(因为磁盘上的真实文件具有不同的名称)。一些名称必须包含法国口音(例如é)。当我下载档案时,重音符在文件名中未正确显示。应该使用什么编码的文件名? (应用程序使用UTF-8)

解决方案

这是php bug#53948,请参阅官方错误报告



建议的解决方法(适用于我)$($ UTF-8),CP852,$ local_name ));


I'm using the php ZipArchive class in order to generate a zip archive. I use the second parameter of the addFile method in order to set the name of the file in the archive (since the real file on disk has a different name). Some of the names must contain french accents (such as é). When I download the archive, the accents aren't correctly displayed in the file name. What encoding should I use for the file names ? (the application uses UTF-8)

解决方案

It is php bug #53948, see official bug report.

Suggested workaround (worked for me):

$zip->addFile($file, iconv("UTF-8", "CP852", $local_name));

这篇关于ZipArchive使用哪些编码在创建的存档中存储文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆