views:

1410

answers:

2

I'm trying to store some data in a SQL Server database through php.

Problem is that special chars aren't converted properly. My app's charset is iso-8859-1 and the one used by the server is windows-1252.

Converting the data manually before inserting doesn't help, there seems to be some conversion going on.

Running the SQL query 'set char_convert off' doesn't help either.

Anyone have any idea how I can get this to work?

EDIT: I have tried ini_set('mssql.charset', 'windows-1252'); as well, but no result with that one either.

A: 

You can use the mysql_set_charset function: http://it2.php.net/manual/en/function.mysql-set-charset.php

mck89
mysql_set_charset is for MySQL, but the question mentions mssql (sql server) two times.
VolkerK
+1  A: 

Can't you just convert your tables to your application encoding? Or use utf-8 in both?

I don't know whether MSSQL supports table-level encodings, though.

Also, try the MB (multibyte) string functions, if the above fails.

SeriousWorm
Unfortunately, I can't. For it is not my database, and it's not my framework either. Converting special characters to entities is not an option either, since there is some non-web software connected to this db aswell.I'm used to converting with iconv, but I'll give MB a try.
Maurice
Same results with mb. It seems there is some automatic conversion done while sending data to db.
Maurice