title: Nodejs: how to send the http response in windows-1252
body: <p>I have a nodejs site and at some point it can generate a XML file fomr a database. The problem is that all is in utf-8 but for this specific case, i need that both content and file are in windows-1252.</p>
  <pre><code>                const W1252 = require('windows-1252'); //https://www.npmjs.com/package/windows-1252
                  ...
                  r.header('Content-Disposition', 'attachment; filename=sample.xml');
                  r.header('Content-Type', 'text/xml; charset=windows-1252');
                  r.write(W1252.encode(`&lt;?xml version=&quot;1.0&quot; encoding=&quot;windows-1252&quot;?&gt;&lt;x&gt;€Àáção&lt;/x&gt;`, {
                      'mode': 'html'
                  }));
                  r.end();
                  ...
  </code></pre>
  <p>But this does not work. When the client browser downloads this file, it saves it as charset utf-8. I test it doing:</p>
  <pre><code>file -i sample.xml 
  text/xml; charset=utf-8
  </code></pre>
  <p>The browser response headers mentions windows-1252. I am puzzled! Can anyone tell me what i am missing? Thank you.
  <a href="https://i.stack.imgur.com/6TjxG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6TjxG.png" alt="The browser response headers mention windows-1252" /></a></p>