PHP中用freetds连接到mssql中文乱码问题

在PHP平台上用freetds连接到mssql数据库时出现了乱码问题。具体是用freetds连接调用一个mssql的存储过程,但是返回的结 果却出现了乱码,PHP端是UTF-8。刚开始以为是mssql的编码问题,因为在mssql中就是GB2312的。后来查了一下资料发现可以修改 freetds的配置文件来解决这个问题。添加 client charset = GB2312 行。

#   $Id: freetds.conf,v 1.12 2007/12/25 06:02:36 jklowden Exp $
#
# This file is installed by FreeTDS if no file by the same
# name is found in the installation directory. 
#
# For information about the layout of this file and its settings,
# see the freetds.conf manpage "man freetds.conf". 

# Global settings are overridden by those in a database
# server specific section
[global]
        # TDS protocol version
;       tds version = 4.2

        # Whether to write a TDSDUMP file for diagnostic purposes
        # (setting this to /tmp is insecure on a multi-user system)
;       dump file = /tmp/freetds.log
;       debug flags = 0xffff

        # Command and connection timeouts
;       timeout = 10
;       connect timeout = 10

        # If you get out-of-memory errors, it may mean that your client
        # is trying to allocate a huge buffer for a TEXT field. 
        # Try setting 'text size' to a more reasonable limit
        text size = 64512
        client charset = GB2312

# A typical Sybase server
[egServer50]
        host = symachine.domain.com
        port = 5000
        tds version = 5.0

# A typical Microsoft server
[egServer70]
        host = ntmachine.domain.com
        port = 1433
        tds version = 7.0

你可能感兴趣的:(数据库,PHP,中文乱码,MSSQL,FreeTDS)