编码是不妥当的,当来自Apache / PHP查询 [英] Encoding is not proper when query from Apache/PHP

查看:199
本文介绍了编码是不妥当的,当来自Apache / PHP查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题,连接到我的Vertica公司。

我使用PHP和PDO ODBC驱动程序(thrue的unixODBC)。

当我通过从表isql和选择记录连接到Vertica的所有数据都很好EN codeD - 使用UTF-8个字段(非ASCII符号,例如西里尔)正确打印

如果从网页与PHP脚本连接并执行该字段相同的查询有一定的UNI code字像这样\\ u001A \\ u001A \\ u001A \\ u001A

每个\\ u001A重新present一个非ASCII符号,并不能打印。

I have some problem with connection to my Vertica.
I use PHP and PDO ODBC driver (thrue unixODBC).
When I connect to Vertica via isql and select records from table all data are fine encoded - fields with UTF-8 (non ASCII symbols, for example cyrillic) correctly prints.
If connect from web with PHP script and execute same query that fields has some unicode characters like this \u001A\u001A\u001A\u001A
Each \u001A represent a one non ASCII symbol and can't be printed.

我发现,只有当你从网络上运行的脚本(Web服务器的Apache2)发生此问题。

所以,如果你从控制台运行脚本,它的确定。

但是,如果你从本地主机/ test.php的做到这一点,我们得到的问题。

它发生在Linux和Windows客户端Vertica的司机X32和x64版本。

如何在Apache能影响结局的结果,我们从Vertica的获得?

I found that this problem occurs only when you run a script from the web (web server is Apache2).
So if you run the script from the console, it's OK.
But if you do it from localhost/test.php, we get the issue.
It occurs on x32 and x64 versions of Vertica client drivers for Linux and Windows.
How does the Apache can influence the outcome results that we get from Vertica?

推荐答案

其需要添加的语言环境直接设置到PHP code,一切都开始工作。

Needs to added locale setting directly to PHP code and everything start to work

setlocale(LC_ALL, 'en_US.UTF-8');

这篇关于编码是不妥当的,当来自Apache / PHP查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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