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 ?
Solution found:
Had to decode utf8 in server response.
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;
});
You need to put **decode_utf8();**
into your php file on your server
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);
1 Like