I'm changing a website to use the UTF-8 character set from iso-8859-1.
When i change this:
<meta http-equiv='content-type' content='text/html; charset=iso-8859-1' />
to
<meta http-equiv='content-type' content='text/html; charset=utf-8' />
It all appears to work fine and posting forms sends the data in UTF-8. Perfect.
But when i set this
<?php header('Content-Type: text/html; charset=utf-8'); ?>
The javascript includes break which i wasn't expecting. Obviously there is some 3rd party code in their that uses characters in iso-8859-1 encoding that doesn't change to utf-8 correctly. So fixing the javascript code itself is easy enough.
HTTP Header Set to UTF-8 + HTML Content Type Set to UTF-8
As expected, it hints that everything is using UTF-8, however, it breaks the javascript include... It also only breaks the js include on FireFox. I tested this configuration on IE, Chrome and Opera and it works fine. For this reason i'm starting to think maybe FireFox is at fault here and this is a bug in the browser (though a simple fix for FireFox is to add chartset='iso-8859-1' to the script tag).
HTTP Header set to iso-8859-1 + HTML Content Type Set to UTF-8
I was always under the impression that the HTTP header SHOULD overwrite any inconsistant character sets defined in the HTML header. However, it appears JS includes listen to the HTTP character set... while posting data ignores the HTTP header and listens to the HTML character set instead!?
Can anybody explain why and is it supposed to happen this way or is it possibly a bug in FireFox 17.0.1?
If you can control the buffering, use http://php.net/manual/en/function.utf8-encode.php else, just alter the Javascript and make it UFT-8.
About the question... the php header controls the output sent by the server so, the PHP will alter the content. That META tag is just an info for the browser "be careful, this is UTF-8".