Support » Fixing WordPress » UTF-8 charset in HTTP headers missing

  • Not exactly a beta, but I tried the 2004-08-10 nightly just now. And stumbled over something I allways notice with software that want’s to serve HTML pages with UTF-8 charset. The pages include a meta tag telling about the charset – but the server still sends out the default charset in the HTTP headers in requests. Many browsers regard – correctly – the HTTP header higher than the meta tag. It would be a very good idea to add header(…) calls to the wp-blog-header and admin-header in WordPress so that all pages are served with the correct HTTP header. Sure, people could change that in the Apache configuration, but usually this isn’t done. Setting it explicitely in the pages is much better – and you actually try to do that already with the meta tags.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can’t send a charset alone, it needs an accompanying mime-type.
    If we wanted to send a charset, we would have to pick a mime-type for pages, and sooner or later someone will blog “OMG WP serves XHTML as text/html, it’s considered harmful!” or “OMG WP serves XHTML as application/xhtml+xml, Google can’t read that!”.

    Blame the Apache AddDefaultCharset setting that comes by default in most distros’ Apache. The W3C itself filed a bug against that very setting’s presence in the default httpd.conf.
    Here’s a workaround: “AddDefaultCharset none” in .htaccess.

    But WP _does_ send a content type already with the Content-Type meta tag – adding the exact content type and charset you use there wouldn’t do any more damage as already is done.
    AddDefaultCharset none can only be set in .htaccess if the appropriate options override is allowed for that server configuration. You can’t be sure that this is allways the case. So I think it would be better to add a content-type selection/entry to the preferences to allow HTTP buffs to do what they want and set this to default text/html (as is now the case with the meta tag) and send this out via header(…) call. That way people without the know will get the expected results and pro-users can easily override everything.

    Hmm. This in my .htaccess works fine for me.
    php_value default_charset "utf-8"

    Maybe I had a similar problem. This is what happened to me. Podz’s tip was fantastic and my Chinese characters are no longer nonsense. I took the advice and put into my .htaccess file:
    AddDefaultCharset utf-8

    Moderator Matt Mullenweg



    This has been fixed in the CVS.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘UTF-8 charset in HTTP headers missing’ is closed to new replies.