logo

Problem/Solution with HTML Character Encoding

logo

This is second time I come to strange problem. In html code, inside header tag, I setup page encoding to ISO-8859-1:

meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"

When I opened page in browser, it showing me some strange characters(ttis was page about some french products), and the problem is because browser render page using utf-8 encoding. Because I have no control over content, and converting content into ut8-8 encoding would not be easy, because content is coming from external sources.

After digging a bit, I found that the problem is because apache default encoding was utf-8, and it overwrite encoding setup in html header.

Fortunately, solution was easy, and only thing I have to do is to change apache default encoding. This can be done in main apache config file(httpd.conf) for all sites on that web server, in VirtualHosts section of same file, or in .htaccess file.
Because my site is on shared hosting and I don’t have access to httpd.conf, I simple change default apache encoding in .htaccess. I added next line:

AddDefaultCharset iso-8859-1

And it worked perfect!

Leave a Reply

logo
logo
Copyright ©NeithStudio 2010