最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

json - How to decode into UTF-8 using angular js or Javascript - Stack Overflow

programmeradmin4浏览0评论

I started recently to use angular js, I like how it works, I want to know how can I set the charset encoding as a header.

My json file contains special characters ( French language ).

something like : Remplaçant

Is there any way to decode that into UTF-8 after retreiving it :

here is my code :

$http.get(".json"
})
        .success(function (response) {
            $scope.lineup = response;    

        });

I started recently to use angular js, I like how it works, I want to know how can I set the charset encoding as a header.

My json file contains special characters ( French language ).

something like : Remplaçant

Is there any way to decode that into UTF-8 after retreiving it :

here is my code :

$http.get("http://int.footballclub.orange./live/lineup/fr_lineup_253959.json"
})
        .success(function (response) {
            $scope.lineup = response;    

        });
Share Improve this question asked May 28, 2015 at 8:43 Yasser B.Yasser B. 8357 gold badges21 silver badges34 bronze badges 1
  • JSON file MUST BE in UTF-8 initially. – zerkms Commented May 28, 2015 at 8:52
Add a ment  | 

1 Answer 1

Reset to default 4

As you initially said, you can add a request header. That way you don't have to translate it if the server supports UTF-8.

An example by Banasci:

$http.get('resources/negozi.json',
    {headers : {'Content-Type' : 'application/json; charset=UTF-8'}
}).success(function(data) {
... code here
});

Also, see the documentation.

发布评论

评论列表(0)

  1. 暂无评论