I have a client who has a mobile web application in 52 languages and recently we moved them to a shiny new cpanel web server and suddenly the encoding broke, resulting in any non english characters displaying as ?? and diamonds with question marks in them.
AGGGHHHH!!!! Client is flipping out and we are mystified so we spent pretty much all day on thursday and all day on friday trying to figure it out.
Nothing seemed to work despite trying everything…….
Yes – the charset was set to <meta charset=”utf-8″ />
Yes – the mobile application is set to html5
Yes – the master php.ini file was set to AddDefaultCharset UTF-8
Yes – we included AddDefaultCharset UTF-8 in htaccess file
Yes – the server httpd.conf file included AddDefaultCharset UTF-8
Yes – we tried adding ini_set(‘mssql.charset’, ‘utf-8’); to the application
Yes – we are storing the source data in mssql ntext format
Yes – we tried html_entity_decode($TheText, ENT_QUOTES , “utf-8”);
Yes – we tried iconv(“utf-8”, “utf-8//IGNORE”, $TheText);
Yes – we tried iconv(‘utf-8’, ‘ASCII//TRANSLIT’, $TheText);
Yes – we tried setlocale(LC_CTYPE, ‘tr_TR’);
yes – we tried iconv(‘utf-8′,’iso-8859-2’,$TheText);
Yes – we tried ini_set(‘mssql.charset’, ‘cp1252’);
Yes – I had the data centre senior admin check the issue (no luck from him)
What worked in the end?
So early on sunday morning I got up fresh and started to look around for more clues as to a solution and literally within a few minutes I found the link: http://stackoverflow.com/questions/1322421/php-sql-server-how-to-set-charset-for-connection and noticed someone made a comment saying:
“I had the same problem and ini_set('mssql.charset', 'utf-8');
did not work for me. However, it worked in uppercase”.
So I added ini_set(‘mssql.charset’, ‘UTF-8’); to the config file in the mobile application and everything started working perfectly again!
DOH! Something so simple.