title: How to encode the filename parameter of Content-Disposition header in HTTP?
body: <p>Web applications that want to force a resource to be <em>downloaded</em> rather than directly <em>rendered</em> in a Web browser issue a <code>Content-Disposition</code> header in the HTTP response of the form:</p>
  <p><code>Content-Disposition: attachment; filename=<em>FILENAME</em></code></p>
  <p>The <code>filename</code> parameter can be used to suggest a name for the file into which the resource is downloaded by the browser. <a href="https://www.rfc-editor.org/rfc/rfc2183" rel="noreferrer">RFC 2183</a> (Content-Disposition), however, states in <a href="https://www.rfc-editor.org/rfc/rfc2183#section-2.3" rel="noreferrer">section 2.3</a> (The Filename Parameter) that the file name can only use US-ASCII characters:</p>
  <blockquote>
  <p>Current [RFC 2045] grammar restricts
  parameter values (and hence
  Content-Disposition filenames) to
  US-ASCII.  We recognize the great
  desirability of allowing arbitrary
  character sets in filenames, but it is
  beyond the scope of this document to
  define the necessary mechanisms.</p>
  </blockquote>
  <p>There is empirical evidence, nevertheless, that most popular Web browsers today seem to permit non-US-ASCII characters yet (for the lack of a standard) disagree on the encoding scheme and character set specification of the file name. Question is then, what are the various schemes and encodings employed by the popular browsers if the file name “naïvefile” (without quotes and where the third letter is U+00EF) needed to be encoded into the Content-Disposition header?</p>
  <p>For the purpose of this question, <em>popular browsers</em> being:</p>
  <ul>
  <li>Google Chrome</li>
  <li>Safari</li>
  <li>Internet Explorer or Edge</li>
  <li>Firefox</li>
  <li>Opera</li>
  </ul>