xref: /PHP-8.0/ext/json/tests/bug46944.phpt (revision 32a1ebbd)
1--TEST--
2Bug #46944 (json_encode() doesn't handle 3 byte utf8 correctly)
3--FILE--
4<?php
5
6for ($i = 1; $i <= 16; $i++) {
7    $first = 0xf0 | ($i >> 2);
8    $second = 0x8f | ($i & 3) << 4;
9    $string = sprintf("aa%c%c\xbf\xbdzz", $first, $second);
10    echo json_encode($string) . "\n";
11}
12
13
14echo "Done\n";
15?>
16--EXPECT--
17"aa\ud83f\udffdzz"
18"aa\ud87f\udffdzz"
19"aa\ud8bf\udffdzz"
20"aa\ud8ff\udffdzz"
21"aa\ud93f\udffdzz"
22"aa\ud97f\udffdzz"
23"aa\ud9bf\udffdzz"
24"aa\ud9ff\udffdzz"
25"aa\uda3f\udffdzz"
26"aa\uda7f\udffdzz"
27"aa\udabf\udffdzz"
28"aa\udaff\udffdzz"
29"aa\udb3f\udffdzz"
30"aa\udb7f\udffdzz"
31"aa\udbbf\udffdzz"
32"aa\udbff\udffdzz"
33Done
34