mirror of
https://github.com/php/php-src.git
synced 2026-03-26 01:02:25 +01:00
json_decode() returns a binary string, not unicode for efficiency, and if you are going to test invalid utf8 in a test, you have to stuff it into a binary string or it will be valid unicode by definition.
21 lines
410 B
PHP
21 lines
410 B
PHP
--TEST--
|
|
Bug #43941 (json_encode() invalid UTF-8)
|
|
--SKIPIF--
|
|
<?php if (!extension_loaded("json")) print "skip"; ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
var_dump(json_encode(b"abc"));
|
|
var_dump(json_encode(b"ab\xE0"));
|
|
var_dump(json_encode(b"ab\xE0c"));
|
|
var_dump(json_encode(array(b"ab\xE0", b"ab\xE0c", b"abc")));
|
|
|
|
echo "Done\n";
|
|
?>
|
|
--EXPECT--
|
|
string(5) ""abc""
|
|
string(4) "null"
|
|
string(4) "null"
|
|
string(17) "[null,null,"abc"]"
|
|
Done
|