0

I have a SQL Server table that contains country names translated into various languages. I am attempting to display this in a web page. However, what is stored in the database as Amérique du Nord comes out in PHP as Amérique du Nord

My PDO connection string is

sqlsrv:SERVER=<SERVER>;DATABASE=<DATABASE>

There is no charset option for SQL Server, but the default according to the documentation is UTF-8.

I have tried casting the column to varbinary, but that just gives me an ascii number that I have not been able to convert to a character. I have also tried a few variations of mb_character_encode which ended up making the characters Chinese.

For additional information:

I am on IIS 7.5, running PHP through FastCGI.

The script is sending the utf-8 header.

On other areas of the same page, I am successfully outputting UTF-8 that I am reading in from a .po file. Only text from the database query is mis-encoded.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Wige
  • 3,788
  • 8
  • 37
  • 58
  • `é` is exactly `é` properly encoded as UTF-8 and misinterpreted as Windows-1252 or similar. Is your PHP application using UTF-8? – Álvaro González Dec 09 '15 at 15:09
  • As far as I can tell it is - I am setting the header using `header('Content-Type: text/html; charset=utf-8');` and have set the `mb_internal_encoding("UTF-8");` as well. Is there something else I need to set or change? (The application is on IIS) – Wige Dec 09 '15 at 15:38
  • The first item declares the page as UTF-8 (which doesn't mean it's actually using UTF-8). The second item is unrelated to page encoding AFAIK. Please let me link to the usual question. – Álvaro González Dec 09 '15 at 15:43
  • 1
    The question you marked this as a duplicate of is responding to a question on a different platform (Apache) and a different database (MySQL). None of the settings in the answer to that question exist on MSSQL connections via PDO. – Wige Dec 09 '15 at 16:20
  • What encoding of table? – Nick Dec 09 '15 at 21:03
  • The character set is Unicode, the collation is SQL_Latin1_General_CP1_CI_AS – Wige Dec 10 '15 at 13:17

0 Answers0