UTF8 doesn't get parsed by php, server related ? not file related

Go To StackoverFlow.com


this is so weird, this has never happened to me. I've worked with utf-8 alot and this is the first time happening, Since last week all my sites that had utf8 characters in files are now showing ? instead of the actual character!

the files are ok and I can see characters fine if I edit them,but after it gets processed by php it changes the utf-8 characters with ?.

the utf8 characters that were stored in database are loading just fine , but the problem is with the strings that are in php files.

Notice I said since last week, this means it happened all of a sudden and obviously something changed on server. I contacted my hosting company but they have no clue what to look for and I don't know what to tell them to look for.

any clue what could have been changed on the server?

so to conclude:

  • it's not a database problem
  • it's not a file encoding problem (I hope not, I have 30+ sites with different cms on each one, can not afford to edit them all)
  • it's not a content-type issue in html because it's getting parsed by php and turns utf8 characters to ?
  • it could alse be a wordpress problem,but I'm sure this happend after some changes on server side

screenshot1 screenshot2

2012-04-04 06:32
by Danny
can you try to isolate the problem and give a small piece of demonstration code of your "utf-8 parsing"? I assume it's because of the HTTP Content-Type header changed, but you mention it cannot be a problem with content type. so give us an example please - Kaii 2012-04-04 06:41
ok for example it changes : قیمت to ????? (I looked in the html source code too,after it's loaded its question marks )besides I have like 30+ sites with different html codes some don't have content-type,but most of them have it and they have the same problem - Danny 2012-04-04 06:42
And please give some more information: what webserver and what php version is this? Apache 2 + mod_php 5.3.x - Kaii 2012-04-04 06:42
Is it the actual ? character or the � character for invalid byte-sequenc - ontrack 2012-04-04 06:42
I know what it changes the characters to. I was asking for example codeKaii 2012-04-04 06:42
ok here are screenshots screen1 screen2Danny 2012-04-04 06:46
PHP Version : 5.2.17 , LiteSpeed V5. - Danny 2012-04-04 06:53
ok, i looked at the site woodpress.ir headers in firebug (this is the site that you say in your screenshot).

In the header response, content-type is utf-8, but when i right click on the page and see "page info", it says "Standards Compliance Mode"....please put this in your page: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> and try again - web-nomad 2012-04-04 06:53

I already said that I don't think it's html/file related, I did it anyway, check again nothing has changed - Danny 2012-04-04 06:58
Do you use output buffering and are you doing anything string related there? What are you doing to the strings - deceze 2012-04-04 07:09
I do absolutely nothing, it was all ok ,this happend suddenly 1 week ago - Danny 2012-04-04 07:11
Double check it's not an encoding issue during file transfer (i.e. when you upload your templates). Try uploading a very simple doc with no php in it. If these strings are also stored into the DB - have a look at the DB/table/column encoding - Grigorash Vasilij 2012-04-04 07:16
no it's not from the database,these strings aren't stored in db,they are saved in file,db strings are loading just fine. it could also be wordpress problem,but something must have changed on serve - Danny 2012-04-04 07:23


  • it's not a database problem - Check
  • it's not a file encoding problem - THIS actually could be it
  • it's not a content-type - Check (but make sure you write UTF-8 in meta tag lowercase !)
  • Wordpress problem - Maybe with combination of file encoding

I can imagine situation, when you deleted/disabled mb_string module for PHP and then edited your template using wordpress. Then your characted got shattered.

2012-04-04 07:56
by Marakoss
it might actually be the mb_string's fault . if they have changed or deleted/disabled it, it might cause it. I realized something after a couple of tests, the files that have been saved with utf-8 with BOM are showing the question marks,if I save them again with utf-8 it will solve the problem. but I have too many files on many sites,that can't be done. does anyone have any idea how to solve this by server change ? I want to tell my hosting to do it - Danny 2012-04-04 08:00
If you're not programmer, ask you hosting provider to do it. Otherwise write yourself a simple script that will do the job - Marakoss 2012-04-04 08:08
I want to keep the option of changing files encoding to the last, because most editors save with utf-8 with bom as default and this will keep happening,I'll try to talk to my host,btw can "enable-zend-multibyte" cause this - Danny 2012-04-04 11:12
ok my host is avoiding the problem because they don't know how to fix it,they sat the only thing they have done is rebuilt the PHP. does anybody have any idea - Danny 2012-04-05 04:57