How to set character encoding for MSSQL connection
Posted: Wed May 12, 2010 10:06 am
Hello,
Could someone please advise how to set the character encoding for MSSQL connection, when using php on IIS?
The setup is as follows:
- Win 2003 server with IIS (6.0) and PHP (5.2.10) on it.
- MSSQL server 8.00.2039 SP4, default code page windows-1257
Standard php code like
$conn=mssql_connect('server','user','pwd') or die ("cannot connect<br>");
mssql_select_db("DB_Name");
$res=mssql_query("SELECT bla bla bla");
The problem is that data in $res are stored in windows-1257 encoding, thus garbling unicode characters that do not exist in this code page. How to force php to perform the conversation between php and sql server in utf-8? I know how to do it, when using php on Linux server (using freetds), but I could not find any advice online, how to do the same for php on Win PC.
Passiday
Could someone please advise how to set the character encoding for MSSQL connection, when using php on IIS?
The setup is as follows:
- Win 2003 server with IIS (6.0) and PHP (5.2.10) on it.
- MSSQL server 8.00.2039 SP4, default code page windows-1257
Standard php code like
$conn=mssql_connect('server','user','pwd') or die ("cannot connect<br>");
mssql_select_db("DB_Name");
$res=mssql_query("SELECT bla bla bla");
The problem is that data in $res are stored in windows-1257 encoding, thus garbling unicode characters that do not exist in this code page. How to force php to perform the conversation between php and sql server in utf-8? I know how to do it, when using php on Linux server (using freetds), but I could not find any advice online, how to do the same for php on Win PC.
Passiday