1--TEST--
2json_decode() invalid UTF8
3--FILE--
4<?php
5function json_decode_invalid_utf8($str) {
6    var_dump(json_decode($str));
7    var_dump(json_decode($str, true, 512, JSON_INVALID_UTF8_IGNORE));
8    $json = json_decode($str, true, 512, JSON_INVALID_UTF8_SUBSTITUTE);
9    if (is_array($json)) {
10        var_dump(array_map(function($item) { return bin2hex($item); }, $json));
11    } else {
12        var_dump(bin2hex($json));
13    }
14}
15json_decode_invalid_utf8("\"a\xb0b\"");
16json_decode_invalid_utf8("\"a\xd0\xf2b\"");
17json_decode_invalid_utf8("\"\x61\xf0\x80\x80\x41\"");
18json_decode_invalid_utf8("[\"\xc1\xc1\",\"a\"]");
19echo "Done\n";
20?>
21--EXPECT--
22NULL
23string(2) "ab"
24string(10) "61efbfbd62"
25NULL
26string(2) "ab"
27string(16) "61efbfbdefbfbd62"
28NULL
29string(2) "aA"
30string(22) "61efbfbdefbfbdefbfbd41"
31NULL
32array(2) {
33  [0]=>
34  string(0) ""
35  [1]=>
36  string(1) "a"
37}
38array(2) {
39  [0]=>
40  string(12) "efbfbdefbfbd"
41  [1]=>
42  string(2) "61"
43}
44Done
45