Use <meta charset=UTF-8> in HTML5
authorAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 21 Mar 2010 05:12:15 +0000 (05:12 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Sun, 21 Mar 2010 05:12:15 +0000 (05:12 +0000)
More succinct than <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />.  HTML5 allows it because all browsers support it
anyway -- authors would forget quotes, leading to <meta
http-equiv=Content-Type content=text/html; charset=UTF-8 />, so browsers
all treat "charset" as an attribute of <meta> that does what you expect.

includes/OutputPage.php

index 4a2b819..3685f5d 100644 (file)
@@ -2075,7 +2075,6 @@ class OutputPage {
                global $wgContLang, $wgUseTrackbacks, $wgStyleVersion, $wgHtml5, $wgWellFormedXml;
                global $wgUser, $wgRequest, $wgLang;
 
-               $this->addMeta( "http:Content-Type", "$wgMimeType; charset={$wgOutputEncoding}" );
                if ( $sk->commonPrintStylesheet() ) {
                        $this->addStyle( 'common/wikiprintable.css', 'print' );
                }
@@ -2117,6 +2116,7 @@ class OutputPage {
                        foreach ( $wgXhtmlNamespaces as $tag => $ns ) {
                                $htmlAttribs["xmlns:$tag"] = $ns;
                        }
+                       $this->addMeta( 'http:Content-Type', "$wgMimeType; charset=$wgOutputEncoding" );
                }
                $ret .= Html::element( 'html', $htmlAttribs ) . "\n";
 
@@ -2126,6 +2126,13 @@ class OutputPage {
                        $ret .= "$openHead\n";
                }
                $ret .= "<title>" . htmlspecialchars( $this->getHTMLTitle() ) . "</title>\n";
+
+               if ( $wgHtml5 ) {
+                       # More succinct than <meta http-equiv=Content-Type>, has the
+                       # same effect
+                       $ret .= Html::element( 'meta', array( 'charset' => $wgOutputEncoding ) ) . "\n";
+               }
+
                $ret .= implode( "\n", array(
                        $this->getHeadLinks(),
                        $this->buildCssLinks(),