Monday, 15 July 2013

PHP utf8 and json_encode accent mark problems -



PHP utf8 and json_encode accent mark problems -

i have text coming csv total of accent marks. check if mb_check_encoding($my_text, 'utf-8') true, , yes, is. text generate variable $json apply

json_encode($json,json_numeric_check); var_dump($json)

gives array of arrays unusual marks right (é, ì, etc), generated json text wrong (ex: "donn\u00e9es" instead of "données").

i know json_encode works fine utf8 encoded data, that's why checked before utf8. tried adding header("content-type: application/json; charset=utf-8"); without success.

then reason of that?

this how json encodes "strange marks", i.e. unicode characters. when utilize json_decode() on json-encoded string, homecoming normal.

php

No comments:

Post a Comment