Debian上具有unixodbc的iSeries Access ODBC驱动程序-从iSeries返回无效的UTF-8字符 [英] iSeries Access ODBC Driver with unixodbc on Debian - Invalid UTF-8 characters being returned from iSeries
问题描述
在Debian Linux上使用ODBC驱动程序ibm-iaccess-1.1.0.10-1.0.amd64.当我执行php sql查询并验证响应时,我看到返回的某些数据无效utf-8.
Using ODBC driver, ibm-iaccess-1.1.0.10-1.0.amd64, on Debian Linux. When I perform a php sql query and validate the response, I see some of the data returned is not valid utf-8.
mb_check_encoding返回'false',而在chrome浏览器中屏幕上的字符是菱形问号字符.
mb_check_encoding returns 'false' and the character on screen in a chrome browser is the diamond question mark character.
这发生在一些CHAR字段类型上.
This happens on a few CHAR field types.
if(!mb_check_encoding($row["field"])) {
... exit with utf-8 error
}
我可以通过将UTF-8转换为UTF-8来解决此问题:
I can work around this by converting from UTF-8 to UTF-8:
mb_convert_encoding($row["field"], 'UTF-8', 'UTF-8');
/etc/odbc.ini:
/etc/odbc.ini:
[as400]
Description = iSeries Access ODBC Driver
Driver = iSeries Access ODBC Driver
system = as400
Naming = 0
DefaultLibraries = *usrlibl
DefaultPkgLibrary = QGPL
DefaultPackage = A/DEFAULT(IBM),2,0,1,0,512
ConnectionType = 0
CommitMode = 1
ExtendedDynamic = 1
AllowDataCompression = 1
AllowUnsupportedChar = 0
ForceTranslation = 1
Trace = 0
Charset = UTF-8
/etc/odbcinst.ini:
/etc/odbcinst.ini:
Description=IBM i Access for Linux 64-bit ODBC Driver
Driver=/usr/lib/libcwbodbc.so
Setup=/usr/lib/libcwbodbcs.so
fileusage=1
dontdlclose=1
此外,IBM是否记录了任何odbc参数?看来这是盲目地尝试参数,直到有效果为止.
Additionally, does IBM document any of the odbc parameters? It seems like this is blindly trying parameters until something works.
推荐答案
单字节安装OS/400总是通过ODBC将Latin1字符集返回给Linux.这是根据我对非常旧版本(V4)的经验得出的.几个月前,我深入研究了文档,看来它仅提供带有DBCS安装的UTF-8.
A single byte install of OS/400 always returns Latin1 charset via ODBC to Linux. This is from my experience with very old versions (V4). I digged into documentation a few months ago and it seems to provide UTF-8 only with a DBCS-Install.
我不能说当前版本的i是否仍然适用.
I can't say if this is still true for current versions of i.
这篇关于Debian上具有unixodbc的iSeries Access ODBC驱动程序-从iSeries返回无效的UTF-8字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!