Forum Moderators: coopster
Working with PHP 4.4 and mySQL 4.1, I've got some texts stored in a UTF-8 table with special chars.
I serve a UTF-8 header within my HTML, Apache is configured to serve UTF-8 and PHP scripts are saved in UTF-8 charset.
However, sometimes I get 'Espaņa' and other times 'Espa�a'. The difference? I press F5 (Refresh) bottom on my web browser (I use Firefox and Internet Explorer).
Any similar experience?
When I have suffered problems with special chars I use utf8_decode or utf8_encode, but I always try to store text data in UTF-8 charset and serve them always with UTF-8 PHP scripts.
However, this is a very odd issue, since it happens only with text taken from DataBase, but not from texts written in scripts :(
I am guessing that it may well be an issue with the browser. As the default encoding of the browser is usually set for ISO-8859-1. My theory is that when you hit F5 you get the page from the cache using the default encoding from the browser, not using the content-type header supplied by php the first time around.
Have you tried changing the default encoding on your browser to see if it is a browser issue?
> Is there <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> in the head of the document code?
Yep, there's
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
> I am guessing that it may well be an issue with the browser. As the default encoding of the browser is usually set for ISO-8859-1. My theory is that when you hit F5 you get the page from the cache using the default encoding from the browser, not using the content-type header supplied by php the first time around.
My web browser is in English and it's set to "Unicode (UTF-8)"
And if your theory is right, why do all the UTF-8 webpages of the Internet work? Web browsers would change encoding randomly.
> Have you tried changing the default encoding on your browser to see if it is a browser issue?
I changed it to Western (Latin-1) and it won't work :(