Zend Framework 和使用 iconv 的字符串转换

发布于 2024-08-08 16:43:02 字数 412 浏览 9 评论 0原文

一个站点已移动到另一台安装了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

聽兲甴掵 2024-08-15 16:43:02

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)时,这个话题出现了。我使用以下测试脚本重现了上述错误:

<?php
echo iconv_strlen("hello");
?>

在命令行和浏览器中。经过一些故障排除后,我发现以下方法可以通过以下两种方式之一“解决”当前的问题:

<?php
echo iconv_strlen("hello", 'utf-8');
?>

或者

<?php
iconv_set_encoding("internal_encoding", "UTF-8");
echo iconv_strlen("hello");
?>

在 ZF 中添加 iconv_set_encoding 不起作用。

更改 php.ini 以使更改永久对 ZF 确实有效,

[iconv]
iconv.input_encoding = ISO-8859-1
iconv.internal_encoding = UTF-8
iconv.output_encoding = ISO-8859-1

但是 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:

<?php
echo iconv_strlen("hello");
?>

both on the command line and in browser. After some troubleshooting, I discovered that the following "solved" the immediate problem one of two ways:

<?php
echo iconv_strlen("hello", 'utf-8');
?>

or

<?php
iconv_set_encoding("internal_encoding", "UTF-8");
echo iconv_strlen("hello");
?>

however adding the iconv_set_encoding in ZF did not work.

Changing php.ini to make the changes permanent did work for ZF

[iconv]
iconv.input_encoding = ISO-8859-1
iconv.internal_encoding = UTF-8
iconv.output_encoding = ISO-8859-1

However the original reason why iconv acts up on the new server is beyond me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文