Getting data with UTF-8 charset from MSSQL server using PHP FreeTDS extension

前端 未结 8 1140
暖寄归人
暖寄归人 2020-11-28 09:28

I can\'t seem to get data from MSSQL encoded as UTF-8 using FreeTDS extension.

Connecting:

ini_set(\'mssql.charset\', \'UTF-8\');
$this->_resource         


        
8条回答
  •  情书的邮戳
    2020-11-28 10:07

    You can also solve this issue by adding CharacterSet UTF-8 in the $connectionInfo before connecting to the DB.

    $serverName = "MyServer";
    $connectionInfo = array( "Database"=>"AdventureWorks", "CharacterSet" => "UTF-8");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    

    Worked fine NO additional encoding needed.

提交回复
热议问题