I have a text coming from a CSV full of accent marks.
I check if mb_check_encoding($my_text, 'utf-8') is true, and yes, it is.
With this text I generate a variable $json which apply a
json_encode($json,JSON_NUMERIC_CHECK);
var_dump($json)
gives an array of arrays with all strange marks correct (é, ì, etc), but the generated JSON text is incorrect (ex: "Donn\u00e9es" instead of "Données").
I know that json_encode only works fine for utf8 encoded data, that’s why I checked it before that it was utf8.
I tried also adding a header("Content-type: application/json; charset=UTF-8"); without success.
Then what could be the reason of that?
This is how JSON encodes “strange marks”, i.e. Unicode characters. When you use
json_decode()on your JSON-encoded string, it will return to normal.