HTTP get, UTF-8


#1

Hello,
I am getting data from a server and output it in ionic 2.
However characters like ö,ä,ü etc… are shown as “?”. I want them to display correctly, how can I handle this ?


#2

Solution found:

Had to decode utf8 in server response.


#3

i need to decode reponse like this , how to do it ?

app.controller(‘courseCtrl’, function($scope, $http) {
$http.get(“http://www.xxxxxxcom/dev/course.php”).then(function (response) {
$scope.myData = response.data.records;

});


#4

You need to put **decode_utf8();** into your php file on your server :slight_smile:


#5

Yes thank you
I have found the solution

$http.get(“http://www.xxxxxxx”,
{header : {‘Content-Type’ : ‘application/json; charset=UTF-8’}
}).then(function (response) {
$scope.myData = response.data;

and in my php script

mysqli_set_charset($mysqli, ‘utf8’); // MYSQLI CHARSET UTF-8

while ($row=mysql_fetch_object($q)){

$data[]=$row;
}
echo json_encode($data);