Insert Unicode characters using PHP & # 8594; ODBC & # 8594; MS SQL?

I have the following code:

$sql = "update tbl_test set category = N'resumé'; echo $sql; $rs=odbc_exec($conn,$sql); 

Where $ conn is the ODBC connection for DSN with the MSSQL server. The problem is that somewhere between PHP and MySQL (maybe ODBC?), Unicode characters are converted to unwanted ones. If I copy paste what the echo says directly in Enterprise Manager, it inserts a fine in MS SQL. However, if I run the code, it always goes into MSSSQL as resumà ©. Any idea what I'm missing here?

+5
php unicode odbc
source share
3 answers

The problem is not ODBC, but PHP ... the solution was to use utf8_decode () for the rows returned from the database.

+4
source share

If you are running Windows and running PHP 5.3 using PDO_ODBC with your own SQL client and your intro is UTF-8, this should just work automatically.

+1
source share

I would carefully rub here. Previously, when I was integrating SQL Server and PHP, I came across situations where SQL Server uses 3 to 5 times more storage space than is really necessary for Unicode characters. Depending on how you connect to the database and how the data is encoded. My understanding is that MSFT is working on a new driver (or may have been out for a while) that solves this problem and, as a rule, improves integration with PHP. You might run into problems with some of the old stacks. I recommend looking at the size of the data in the database to make sure that the connection is not filling your data.

Jacob

0
source share

All Articles