While using json_decode
, if there exist any special charecter like "Question mark with Black Diamond" then decode returns empty values.
I have used UTF-8 encode also.
While using json_decode
, if there exist any special charecter like "Question mark with Black Diamond" then decode returns empty values.
I have used UTF-8 encode also.
Your problem seems to be in the json_encode
part and not in the json_decode
part.
Take a look at this: How to keep json_encode() from dropping strings with invalid characters
They suggest to use iconv
before you json_encode
the string to be sure to remove all illegal characters.
To quote the example given:
$stripped_of_invalid_utf8_chars_string = iconv('UTF-8', 'UTF-8//IGNORE', $orig_string);
if ($stripped_of_invalid_utf8_chars_string !== $orig_string) {
// one or more chars were invalid, and so they were stripped out.
// if you need to know where in the string the first stripped character was,
// then see https://stackoverflow.com/questions/7475437/find-first-character-that-is-different-between-two-strings
}
$json = json_encode($stripped_of_invalid_utf8_chars_string);
https://en.wikipedia.org/wiki/JSON#Data_portability_issues - this is what you want? :) Try to print it as UTF sign.