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