title: How to send Unicode JSON over HTTP?
body: <p><a href="https://www.rfc-editor.org/rfc/rfc4627" rel="nofollow noreferrer">RFC 4627</a> section 3 says</p>
  <blockquote>
  <p>JSON text SHALL be encoded in Unicode.  The default encoding is UTF-8.</p>
  </blockquote>
  <blockquote>
  <p>Since the first two characters of a JSON text will always be ASCII
  characters [RFC0020], it is possible to determine whether an octet
  stream is UTF-8, UTF-16 (BE or LE), or UTF-32 (BE or LE) by looking
  at the pattern of nulls in the first four octets.</p>
  </blockquote>
  <blockquote>
  <pre><code>       00 00 00 xx  UTF-32BE
  </code></pre>
  </blockquote>
  <pre><code>       00 xx 00 xx  UTF-16BE
         xx 00 00 00  UTF-32LE
         xx 00 xx 00  UTF-16LE
         xx xx xx xx  UTF-8
  </code></pre>
  <p>I'm serving a UTF-8 encoded JSON string of <a href="http://www.fileformat.info/info/unicode/char/20AC/index.htm" rel="nofollow noreferrer">U+20AC</a> as application/json.</p>
  <pre><code>$ curl -D - http://localhost:8000/test.json
  HTTP/1.0 200 OK
  Server: SimpleHTTP/0.6 Python/2.7.6
  Date: Fri, 15 Jan 2016 09:24:53 GMT
  Content-type: application/json
  Content-Length: 6
  Last-Modified: Fri, 15 Jan 2016 09:23:13 GMT
  
  &quot;€&quot;
  
  $ curl -s http://localhost:8000/test.json | hexdump
  0000000 e222 ac82 0a22                         
  0000006
  </code></pre>
  <p>But both Chrome <em>and</em> Firefox seemed to be using some other encoding, as both show</p>
  <pre><code>&quot;â‚¬&quot;
  </code></pre>
  <p>If change the <code>Content-Type</code> to <code>application/json; charset=utf-8</code>, they show the expected result.</p>
  <p>But <code>charset</code> is a made up addition to <code>application/json</code>, and I'm not sure if it is legal to add extra parameters to it.</p>
  <p>This is all rather confusing.</p>
  <p>Is there a bug somewhere? What's the correct way for me to transmit UTF-8 encoded JSON documents over HTTP?</p>