title: How do I correctly insert unicode in an HTML title using JavaScript?
body: <p>I'm seeing some weird behavior when I'm setting the title of an HTML page using JavaScript.  If I insert html character references directly into the title the Unicode renders correctly, for instance:</p>
  
  <pre><code>&lt;title&gt;&amp;#21543;&amp;#20986;&lt;/title&gt;
  </code></pre>
  
  <p>But if I attempt to use html characters references via JavaScript, something seems to be converting the &amp; to (&amp; amp ;) (separating them so SO doesn't just turn it back into ampersand) and thus breaking the encoding, causing it to be rendered as the full coded string:</p>
  
  <pre><code>function execTitleChange() {
    document.title = "&amp;#21543;&amp;#20986;";
  }
  </code></pre>
  
  <p>(I should note that this is a little bit of speculation; when I introspect the DOM using Firebug after executing this JavaScript function, that's where I see the &amp; instead of &amp;.)</p>
  
  <p>If I use \u encoded Unicode characters when setting the value from JavaScript then everything works correctly again:</p>
  
  <pre><code>function execTitleChange() {
    document.title = "\u5427\u51fa";
  }
  </code></pre>
  
  <p>The fact that \u encoded characters work kind of makes sense to me since I think that's how JavaScript represents Unicode characters but I'm stumped as to why the behavior would be different when using the html character references.</p>