FreeTDS返回带有空字符的字符串

时间:2015-10-30 11:00:48

标签: php sql-server freetds

我正在使用freetds + unixODBC + php pdo_odbc访问MSSQL Server 2012

+ CentOS 7 x86_64
+ freetds version 0.95.19
+ unixODBC version 2.3.4
+ php version 5.6.14

当在UTF-8中从SQL Server中检索结果时,我在长字符串中得到NULL字符(\u0000 in JSON),当由htmlencoded编码的JavaScript变为“ ”时。 我在互联网上找到的唯一一件事就是this post in FreeTDS mailing list

顺便说一下,Microsoft ODBC Driver 11 for SQL Server on Linux在这种情况下运行正常,但还有其他一些我无法解决的问题。

UPD:配置

/etc/freetds.conf

[global]
  text size = 2147483647
[ibmMSSQL]
  host = ibm.sevkav.local
  port = 49927
  tds version = 7.3
  client charset = UTF-8

/etc/odbc.ini

[ODBC Data Sources]

[ibmMSSQL]
Description = MSSQL Server
Trace = No
Servername = ibmMSSQL
Database = MRS

[ibmMSSQLnative]
Driver = SQL Server Native Client 11.0
Description = Test MS Driver
Trace = no
Server = ibm.sevkav.local,49927\EAIS_MIRROR
Database = MRS

[Default]
Driver = FreeTDS

/etc/odbcinst.ini

[ODBC]
#DEBUG=1
#TraceFile=/tmp/sqltrace.log
#Trace=Yes

[PostgreSQL]
Description=ODBC for PostgreSQL
Driver=/usr/lib/psqlodbcw.so
Setup=/usr/lib/libodbcpsqlS.so
Driver64=/usr/lib64/psqlodbcw.so
Setup64=/usr/lib64/libodbcpsqlS.so
FileUsage=1

[MySQL]
Description=ODBC for MySQL
Driver=/usr/lib/libmyodbc5.so
Setup=/usr/lib/libodbcmyS.so
Driver64=/usr/lib64/libmyodbc5.so
Setup64=/usr/lib64/libodbcmyS.so
FileUsage=1

[FreeTDS]
Description=ODBC for FreeTDS
Driver64=/usr/lib64/libtdsodbc.so.0
FileUsage=1
client charset = utf-8

[SQL Server Native Client 11.0]
Description=Microsoft SQL Server ODBC Driver V1.0 for Linux
Driver=/usr/lib64/libsqlncli-11.0.so.1790.0
Threading=1
UsageCount=1

0 个答案:

没有答案