Php – charset=iso-8859-2 webpage displays with UTF-8 header – question marks (�) instead of accented letters

apache-http-serverencodinglatin1PHPutf-8

I have a webserver administration question.
In this website: http://www.mirkaphoto.hu/
All PHP generated pages contain the following line:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />

But this is somehow disregarded probably via the php-apache processing and the page displays in browsers with an UTF-8 header. As a result of that question marks (�) are shown in the page text instead of accented characters (éáöőóüűúí). I tested this in Firefox, IE, Chrome and Seamonkey.

The strangest in this phenomenon, that this symptom started only yesterday, after I upgraded my server to Debian 8.0 Jessie from 7.0 Wheezy. During the upgrade I also upgraded all other packages as well, including apache, php, and so on, and selected "yes" for overwriting config files with factory default ones. After this I fine-tuned my config files to have everything the way I like, but I did not find a way to fix this. Before the upgrade, the page displayed just fine.

Here is a screenshot, where you can see that Firefox sees the "charset=iso-8859-2" definition, but still displays the page with UTF-8 encoding.

screen shot

My suspicion is, that this is a server configuration issue, but it could also be, that one part of the processing component (Apache, php) changed due to the upgrade in some way, resulting this strange behavior. The problem is, I can't pinpoint, what could possibly cause this problem.

Can anyone solve this mistery? What could be possibly going wrong during the processing of the page?

Best Answer

The server’s HTTP headers say

Content-Type: text/html; charset=UTF-8

which browsers would probably consider more trustworthy than what’s inside the file. Why not just use UTF-8? It’s an established encoding on all platforms.

Also, there’s garbage text before the HTML declaration:

[M _2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Related Question