This bug applies to 6.x to
[2007-04-12 18:12 UTC] jp at df5ea dot net
Description: ------------ When decoding a string with surrogate pairs in it, JSON_decode() produces incorrect UTF-8. Instead of encoding the two surrogate characters as one UTF-8 sequence it encodes it as two sequences wich represent the two surrogate code points. The decoded string is actually CESU-8. The JSON_encode() function can not encode such a string. I have a patch to JSON_parse.c that transcodes the UTF-16 properly to UTF-8. Reproduce code: --------------- <?php $single_barline = "\360\235\204\200"; $array = array($single_barline); print bin2hex($single_barline) . "\n"; // print $single_barline . "\n\n"; $json = json_encode($array); print $json . "\n\n"; $json_decoded = json_decode($json, true); // print $json_decoded[0] . "\n"; print bin2hex($json_decoded[0]) . "\n"; print "END\n"; ?> Expected result: ---------------- The output form the two bin2hex functions should be the same: f09d8480 ["\ud834\udd00"] f09d8480 END Actual result: -------------- The second string is different from the input string and illegal UTF-8. f09d8480 ["\ud834\udd00"] eda0b4edb480 END
[2007-04-12 19:41 UTC] iliaa@php.net
[2007-04-12 20:07 UTC] jp at df5ea dot net
[2007-04-15 14:39 UTC] iliaa@php.net
[2007-04-16 21:15 UTC] jp at df5ea dot net
[2007-04-16 22:31 UTC] iliaa@php.net
[2007-04-17 08:25 UTC] jp at df5ea dot net