php-src/ext/mbstring/tests/mb_convert_encoding_failed_detection.phpt
Nikita Popov 5bfa9598f4 Return false from failed mb_convert_variables()
If we fail to detect the encoding return false, just like
mb_convert_encoding() does, and the implementation here clearly
intended. Previously the "pass" pseudo-incoding was returned.
2020-05-07 10:16:46 +02:00

19 lines
472 B
PHP

--TEST--
mb_convert_encoding() when encoding detection fails
--FILE--
<?php
var_dump(mb_convert_encoding("\xff", "ASCII", ["UTF-8", "UTF-16"]));
$str = "\xff";
var_dump(mb_convert_variables("ASCII", ["UTF-8", "UTF-16"], $str));
var_dump(bin2hex($str));
?>
--EXPECTF--
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
bool(false)
Warning: mb_convert_variables(): Unable to detect encoding in %s on line %d
bool(false)
string(2) "ff"