mankee mankee - 1 year ago 83
JSON Question

PHP UTF-8 encoding echoes question marks

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
are sent as question marks as seen in the below image:

enter image description here

I'm not sure how to fix this.

Answer Source

You could try to execute


As a query. After you've made the connection.

Then just in case set this header

header('Content-type: text/plain; charset=utf-8');

Then try again

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download