2

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.com/live/lineup/fr_lineup_253959.json"
})
        .success(function (response) {
            $scope.lineup = response;    

        });
1
  • JSON file MUST BE in UTF-8 initially. Commented May 28, 2015 at 8:52

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

As pointed by the documentation,header should be headersheaders: { 'Content-Type': 'application/json; charset=UTF-8'}

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.