Firefox addon 如何处理Firefox(Jetpack)插件中的编码';s.text?

Firefox addon 如何处理Firefox(Jetpack)插件中的编码';s.text?,firefox-addon,Firefox Addon,我有这样的代码: Request: require('request').Request _makeCall:function(callback){ Request({ url: 'URL-TO-API', contentType: "application/x-www-form-urlencoded; charset=iso-8859-1", content: { op: 'OPERATION-TO-CALL,

我有这样的代码:

Request: require('request').Request
_makeCall:function(callback){
Request({
        url: 'URL-TO-API',
        contentType: "application/x-www-form-urlencoded; charset=iso-8859-1",
        content: {
          op: 'OPERATION-TO-CALL,
          password: 'super-sec,
      user: 'me@gmail.com'
        },
        onComplete: function (response) {
            if(response.status == 200){
                callback(response.text);
            }
            else{
                callback('');
            }
    }
});
req.post();
}
<!DOCTYPE html>
<html>
<head>
<meta charset="iso-8859-1">
API将返回以ISO-8859-1编码的XML结构。返回的数据response.text将包含瑞典字符,如ö、ä和ö。不幸的是,像这样的字符将显示为�. 我在显示文本的面板中使用的html页面如下所示:

Request: require('request').Request
_makeCall:function(callback){
Request({
        url: 'URL-TO-API',
        contentType: "application/x-www-form-urlencoded; charset=iso-8859-1",
        content: {
          op: 'OPERATION-TO-CALL,
          password: 'super-sec,
      user: 'me@gmail.com'
        },
        onComplete: function (response) {
            if(response.status == 200){
                callback(response.text);
            }
            else{
                callback('');
            }
    }
});
req.post();
}
<!DOCTYPE html>
<html>
<head>
<meta charset="iso-8859-1">


我真的被困在这里了,有人知道如何处理这个编码问题吗?

XMLHttpRequest
(它很可能是请求的基础)默认为UTF-8编码。对于不同的编码,服务器的响应需要在
内容类型
标题中指定字符集,例如:

Content-Type: text/html; charset=iso-8859-1

这将确保响应正确转换为Unicode<代码>标记没有帮助。

XMLHttpRequest
(请求最有可能基于此)默认为UTF-8编码。对于不同的编码,服务器的响应需要在
内容类型
标题中指定字符集,例如:

Content-Type: text/html; charset=iso-8859-1
这将确保响应正确转换为Unicode<代码>标记没有帮助