Is there a way to keep json_encode() from returning null for a string that contains an invalid (non-UTF-8) character?
json_encode()
null
It can be a pain in t
Instead of using the iconv function, you can direclty use the json_encode with the JSON_UNESCAPED_UNICODE option ( >= PHP5.4.0 )
Make sure you put "charset=utf-8" in the header of your php file:
header('Content-Type: application/json; charset=utf-8');