mirror of
https://github.com/php/php-src.git
synced 2024-09-22 10:27:25 +00:00
e53162a32b
Instead of returning the encoding of the current substitution character. This allows a robust check for the failure case. The substitution character (especially the default of "?") is also a valid output of mb_chr() for a valid input (for "?" that would be 0x3f), so it's a bad choice for an error value.
43 lines
895 B
PHP
43 lines
895 B
PHP
--TEST--
|
|
mb_chr()
|
|
--SKIPIF--
|
|
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
|
|
--FILE--
|
|
<?php
|
|
var_dump(
|
|
"\u{20bb7}" === mb_chr(0x20bb7),
|
|
"\x8f\xa1\xef" === mb_chr(0x50aa, "EUC-JP-2004"),
|
|
false === mb_chr(0xd800),
|
|
false === mb_chr(0x1f600, "EUC-JP-2004")
|
|
);
|
|
|
|
// Invalid
|
|
var_dump(
|
|
mb_chr(0xd800, "typo"),
|
|
mb_chr(0xd800, "pass"),
|
|
mb_chr(0xd800, "jis"),
|
|
mb_chr(0xd800, "cp50222"),
|
|
mb_chr(0xd800, "utf-7")
|
|
);
|
|
?>
|
|
--EXPECTF--
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
|
|
Warning: mb_chr(): Unknown encoding "typo" in %s on line %d
|
|
|
|
Warning: mb_chr(): Unsupported encoding "pass" in %s on line %d
|
|
|
|
Warning: mb_chr(): Unsupported encoding "jis" in %s on line %d
|
|
|
|
Warning: mb_chr(): Unsupported encoding "cp50222" in %s on line %d
|
|
|
|
Warning: mb_chr(): Unsupported encoding "utf-7" in %s on line %d
|
|
bool(false)
|
|
bool(false)
|
|
bool(false)
|
|
bool(false)
|
|
bool(false)
|