I'm trying to echo a json_response with unicode characters using the following code:
function utf8ize($d) {
if (is_array($d)) {
foreach ($d as $k => $v) {
$d[$k] = utf8ize($v);
}
} else if (is_string ($d)) {
return utf8_encode($d);
}
return $d;
}
used like this:
echo json_encode(utf8ize($response));
The problem with this is that some characters are encoded properly and other characters like ć and ś are sent as question marks as seen in the below image:

I'm not sure how to fix this.
According to http://php.net/manual/en/function.utf8-encode.php
utf8_encodeencodes data from ISO-8859-1 to UTF-8.
However, Polish lang has iso-8859-2 charset so you should use
iconv('iso-8859-2', 'utf-8', $d)
instead of utf8_encode($d)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With