Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js Nodejs:如何在windows-1252中发送http响应_Node.js_Xml_Http_Windows 1252 - Fatal编程技术网

Node.js Nodejs:如何在windows-1252中发送http响应

Node.js Nodejs:如何在windows-1252中发送http响应,node.js,xml,http,windows-1252,Node.js,Xml,Http,Windows 1252,我有一个nodejs站点,在某个时候它可以为数据库生成一个XML文件。问题是所有内容都在utf-8中,但对于这个特定的情况,我需要内容和文件都在windows-1252中 const W1252 = require('windows-1252'); //https://www.npmjs.com/package/windows-1252 ... r.header('Content-Dispositio

我有一个nodejs站点,在某个时候它可以为数据库生成一个XML文件。问题是所有内容都在utf-8中,但对于这个特定的情况,我需要内容和文件都在windows-1252中

                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(`<?xml version="1.0" encoding="windows-1252"?><x>€Àáção</x>`, {
                    'mode': 'html'
                }));
                r.end();
                ...
浏览器响应标题提到了windows-1252。我很困惑!谁能告诉我我错过了什么?非常感谢。

我将使用IConLite:

global.ICONVLITE = require('iconv-lite');

            res.header('Content-Disposition', 'attachment; filename=sample.xml');
            res.header('Content-Type', 'text/xml; charset=iso8859-1');
            res.write(ICONVLITE.encode(`<?xml version="1.0" encoding="windows-1252"?><x>Àáção</x>`, "iso8859-1"));
            r.end();
global.ICONVLITE=require('iconv-lite');
res.header('Content-Disposition','attachment;filename=sample.xml');
res.header('Content-Type','text/xml;charset=iso8859-1');
res.write(ICONVLITE.encode(`oáção`,“iso8859-1”);
r、 end();
global.ICONVLITE = require('iconv-lite');

            res.header('Content-Disposition', 'attachment; filename=sample.xml');
            res.header('Content-Type', 'text/xml; charset=iso8859-1');
            res.write(ICONVLITE.encode(`<?xml version="1.0" encoding="windows-1252"?><x>Àáção</x>`, "iso8859-1"));
            r.end();