Recently I had an annoying little bug. Of course against the golden rule of php I was developing with SQL Server and using php’s mssql functions. All was working well except there were a few records which had special characters within the returned result which php complained about:

Some character(s) could not be converted into client’s character set. Unconverted bytes were changed to question marks (‘?’)

I pondered for quite some time and searched quite a bit. I knew round about what the problem was but couldn’t pinpoint the solution. Finally I ran a phpinfo and checked out my mssql settings. Charset was an available setting. At that point I started searching around for available charsets for php. A nice listing was available for the html_entity_decode function reference.

I started plugging and playing and finally I found one that worked. According to the descriptions I stuck with the Windows based and found that “cp1252” Character Set solved my problems. I just dropped this in where needed:


ini_set('mssql.charset', 'cp1252');

Thats all there was to it to solve the php to mssql character set issues!