Special Characters in Non-English Collation in SQL Server

If you have special characters stored in your records, especially when you are using SQL Server collation other than the default English-language (US) collation "SQL_Latin1_General", you may have trouble display those non-English character such as "Löi, cé".

First of all, make sure to choose the correct database type in conf.php. Choose either odbc_mssql or odbc_mssql_native.  please refer to http://phpgrid.com/documentation/installation/ for complete information.

The methods below demonstrates how to display Chinese (BIG5) characters from SQL Server. 

Method 1:


Add the following line in adodb-mssqlnative.inc.php.

$connectionInfo["CharacterSet"]='UTF-8';

Reference: 
http://blogs.msdn.com/b/brian_swan/archive/2011/02/24/sql-server-driver-for-php-connection-options-characterset.aspx

Method 2:

In data.php, near line 175 change the following from 

$data[] = $row[$col_name]; 

to

$data[] = iconv("BIG5", "UTF-8", $row[$col_name]);

- OR -

$data[] = mb_convert_encoding($row[$col_name], "UTF-8", "BIG5");



Also in the same file, below comment
"// ******************* execute query finally *****************"

Add:

$SQL = iconv("UTF-8","BIG5",$SQL); 

For your reference:
http://stackoverflow.com/questions/16812943/character-set-issue-using-sql-server-and-odbc-in-php

Lis of supported characterset encoding in PHP:
http://php.net/manual/en/mbstring.supported-encodings.php


Feedback and Knowledge Base