0

this problem is driving me nuts. I have a test server and a live server. The test server is showing unicode characters retrieved from an Azure sql database correctly. While the live server running identical code accessing the same data is not showing them correctly.

The data in the database is: Hallo ich heiße Pokémon! Ich würde gerne mal mit einem anderen Kämpfe!

The test servers shows Hallo ich heiße Pokémon! Ich würde etc...

The live server, which is an Azure web service shows Hallo ich hei�e Pok�mon! Ich w�rde gerne mal mit einem anderen K�mpfe

Same PHP code, Same database, Same browser, same db connection string, different web servers, different results.

I do know Azure is running PHP 5.6 and the test server is running PHP 5.3 They are using sqlsrv_connect The data field is type varchar.

I tried using "CharacterSet" => "UTF-8" in the connection but this made no difference to the Azure server and screwed up the result on the test server.

I am out of ideas and leads.

  • Make sure table definitions are the same, i.e. column types and collations – Alex Nov 07 '17 at 01:51
  • Open your browser's web inspector while you make the request in both live and test; ensure that character encoding returned by the server is the same. – miken32 Nov 10 '17 at 05:20

2 Answers2

0

As your application runs on Azure App Service, you could try the following options:

  • Set this in your PHP page:

    header('Content-Type: text/html; charset=UTF-8');
    
  • Create a file named .user.ini to /wwwroot directory with the following content:

    default_charset = "UTF-8"
    
  • Set the responseEncoding attribute of the globalization element in the web.config file:

    <configuration>
        <system.web>
            <globalization 
                requestEncoding="utf-8"
                responseEncoding="utf-8"/>
        </system.web>
    </configuration>
    

More on this: UTF-8 all the way through

Aaron Chen
  • 9,835
  • 1
  • 16
  • 28
0

I swear I tried this before, but this turns out to be the answer

"CharacterSet" => "UTF-8"

added to the connection string, and

<meta charset="UTF-8">

in the web page.