问题
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 returns 'false' and the character on screen in a chrome browser is the diamond question mark character.
This happens on a few CHAR field types.
if(!mb_check_encoding($row["field"])) {
... exit with utf-8 error
}
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:
[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:
Description=IBM i Access for Linux 64-bit ODBC Driver
Driver=/usr/lib/libcwbodbc.so
Setup=/usr/lib/libcwbodbcs.so
fileusage=1
dontdlclose=1
Additionally, does IBM document any of the odbc parameters? It seems like this is blindly trying parameters until something works.
回答1:
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 can't say if this is still true for current versions of i.
来源:https://stackoverflow.com/questions/56364027/iseries-access-odbc-driver-with-unixodbc-on-debian-invalid-utf-8-characters-be