Zend Framework 和使用 iconv 的字符串转换
一个站点已移动到另一台安装了 Solaris 和其他 iconv 设置的服务器。现在,当我使用 Zend Framework 中的“StringLength”函数验证任何内容时,我的脚本因以下错误而失败:
Notice: iconv_strlen() [function.iconv-strlen]: Wrong charset, conversion from `UTF-8' to `UCS-4LE' is not allowed in /usr_files/phplibs/library/Zend/Validate/StringLength.php on line 213
据我所知,服务器确实知道“UCS-4LE”,这是主要问题。
服务器管理员回答说他可以解决这个问题。您对如何在此服务器上设置 ZF 有任何想法吗?
One site was moved to another server where is installed Solaris and other iconv settings. Now, when I validate anything with "StringLength" function from Zend Framework my scripts fail with this error:
Notice: iconv_strlen() [function.iconv-strlen]: Wrong charset, conversion from `UTF-8' to `UCS-4LE' is not allowed in /usr_files/phplibs/library/Zend/Validate/StringLength.php on line 213
As I understood, server does know about "UCS-4LE" and it is main problem.
Server administrator answered that he could resolve this problem. Do you have any ideas how I can setup ZF at this server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
iconv 库需要一个以“UCS-4LE”编码的字符串,但收到的字符串被检测为“UTF-8”。您可能在新服务器上有不同的默认编码。尝试将第三个参数传递给 构造函数 (如
'utf-8'
)。the iconv library was expecting a string encoded in 'UCS-4LE', but received one that it detected as 'UTF-8'. You probably have a different default encoding on the new server. Try passing the third parameter to the constructor (as
'utf-8'
).虽然是一个老话题,但今天当我迁移到运行 xampp 的新服务器(Linux Suse、PHP 5.3.5、Zend Framework 1.11.10)时,这个话题出现了。我使用以下测试脚本重现了上述错误:
在命令行和浏览器中。经过一些故障排除后,我发现以下方法可以通过以下两种方式之一“解决”当前的问题:
或者
在 ZF 中添加 iconv_set_encoding 不起作用。
更改 php.ini 以使更改永久对 ZF 确实有效,
但是 iconv 在新服务器上运行的原始原因超出了我的范围。
Although an old topic, this one came up for me today while moving to a new server running xampp (Linux Suse, PHP 5.3.5, Zend Framework 1.11.10) . I reproduced the above error with the following test script:
both on the command line and in browser. After some troubleshooting, I discovered that the following "solved" the immediate problem one of two ways:
or
however adding the iconv_set_encoding in ZF did not work.
Changing php.ini to make the changes permanent did work for ZF
However the original reason why iconv acts up on the new server is beyond me.