如何使用 angular js 或 Javascript 解码成 UTF-8
How to decode into UTF-8 using angular js or Javascript
我最近开始使用angular js,我喜欢它的工作方式,我想知道如何将字符集编码设置为header。
我的 json 文件包含特殊字符(法语)。
类似于:Remplaçant
有没有办法在检索后将其解码为 UTF-8 :
这是我的代码:
$http.get("http://int.footballclub.orange.com/live/lineup/fr_lineup_253959.json"
})
.success(function (response) {
$scope.lineup = response;
});
如您最初所说,您可以添加请求 header。这样,如果服务器支持 UTF-8,您就不必翻译它。
$http.get('resources/negozi.json',
{headers : {'Content-Type' : 'application/json; charset=UTF-8'}
}).success(function(data) {
... code here
});
另请参阅 documentation。
我最近开始使用angular js,我喜欢它的工作方式,我想知道如何将字符集编码设置为header。
我的 json 文件包含特殊字符(法语)。
类似于:Remplaçant
有没有办法在检索后将其解码为 UTF-8 :
这是我的代码:
$http.get("http://int.footballclub.orange.com/live/lineup/fr_lineup_253959.json"
})
.success(function (response) {
$scope.lineup = response;
});
如您最初所说,您可以添加请求 header。这样,如果服务器支持 UTF-8,您就不必翻译它。
$http.get('resources/negozi.json',
{headers : {'Content-Type' : 'application/json; charset=UTF-8'}
}).success(function(data) {
... code here
});
另请参阅 documentation。