Php/ODBC encoding problem

Posted by JohnM2 on Stack Overflow See other posts from Stack Overflow or by JohnM2
Published on 2010-05-01T14:11:45Z Indexed on 2010/05/01 14:17 UTC
Read the original article Hit count: 235

Filed under:
|
|
|

I use ODBC to connect to SQL Server from PHP. In PHP I read some string (nvarchar column) data from SQL Server and then want to insert it to mysql database. When I try to insert such value to mysql database table I get this mysql error:

Incorrect string value: '\xB3\xB9ow...' for column 'name' at row 1

For string with all ASCII characters everything is fine, the problem occurs when non-ASCII characters (from some European languages) exist.

So, in more general terms: there is a Unicode string in MS SQL Server database, which is retrieved by PHP trough ODBC. Then it is put in sql insert query (as value for utf-8 varchar column) which is executed for mysql database.

Can someone explain to me what is happening in this situation in terms of encoding? At which step what character encoding convertions may take place?

I use: PHP 5.2.5, MySQL5.0.45-community-nt, MS Sql Server 2005.

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about php