在PHP + Apache - 编码问题中压缩含有特殊字符的文件时出现问题 [英] Problem when zipping files with special characters in PHP+Apache - encoding issue

查看:495
本文介绍了在PHP + Apache - 编码问题中压缩含有特殊字符的文件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试在PHP应用程序中压缩文件时遇到编码问题。



这里是处理,每当文件名包含特殊字符:'eñeìá.html',我不能压缩它的权利..使用php函数AddFile将其压缩的结果是'e + | e +¼+í.html'



有问题的是以下行:



$ zip-> addFile($ file_to_add_path,$ file_to_add-> getFilename());



我已经尝试过使用iconv,utf8_decode / encode等,但还没有运气。我使用htmlentities,然后解码它们。



我正在运行的应用程序在Xampp在Win XP操作系统..它可能是有趣的是,当我在应用程序中解压缩之前的文件时,它的名称很好,但是,当我下载压缩文件并打开时it ... bleh ..



无论如何,非常感谢任何人谁可以帮助我或指导我一点。



最好的祝福

解决方案

我有与中欧字符相同的问题,解决使用 iconv(UTF-8,CP852,$ string)其中CP852是中欧的旧DOS编码。所以它可能有助于使用相应的编码为您的语言(我认为它是由内部ZIP算法配置,或任何其他)。


once again I am experiencing problems with encodings when trying to zip files in a PHP application.

Here is the deal, whenever the file name contains special characters, i.e.: 'eñeìá.html', I am not able to zip it right.. the result of zipping it with the php function AddFile is 'e+¦e+¼+í.html'

The problematic line is the following:

$zip->addFile($file_to_add_path, $file_to_add->getFilename());

I have already tried using iconv, utf8_decode/encode, etc. but no luck yet. The closer I got was with the example above when using htmlentities and then decoding them..

I am running the application in Xampp in Win XP OS.. which may be the root of the problem.

Funny thing is, when I unzip the file named before in the application, its name is fine, however, when I download the zipped file and open it... bleh..

Either way, thanks a lot in advance to anyone who could help me out or guide me a bit with this. Should there be more information needed, please do ask me for it.

Best regards

解决方案

I had the same problem with Central European chars, solved using iconv("UTF-8", "CP852", $string); where CP852 is an old DOS encoding for Central Europe. So it might help to use an according encoding for your language (I think it is determined by an internal ZIP algorithm configuration, or whatever).

这篇关于在PHP + Apache - 编码问题中压缩含有特殊字符的文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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