xref: /PHP-7.2/ext/mbstring/tests/mb_chr.phpt (revision e53162a3)
1--TEST--
2mb_chr()
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--FILE--
6<?php
7var_dump(
8    "\u{20bb7}" === mb_chr(0x20bb7),
9    "\x8f\xa1\xef" === mb_chr(0x50aa, "EUC-JP-2004"),
10    false === mb_chr(0xd800),
11    false === mb_chr(0x1f600, "EUC-JP-2004")
12);
13
14// Invalid
15var_dump(
16	mb_chr(0xd800, "typo"),
17	mb_chr(0xd800, "pass"),
18	mb_chr(0xd800, "jis"),
19	mb_chr(0xd800, "cp50222"),
20	mb_chr(0xd800, "utf-7")
21);
22?>
23--EXPECTF--
24bool(true)
25bool(true)
26bool(true)
27bool(true)
28
29Warning: mb_chr(): Unknown encoding "typo" in %s on line %d
30
31Warning: mb_chr(): Unsupported encoding "pass" in %s on line %d
32
33Warning: mb_chr(): Unsupported encoding "jis" in %s on line %d
34
35Warning: mb_chr(): Unsupported encoding "cp50222" in %s on line %d
36
37Warning: mb_chr(): Unsupported encoding "utf-7" in %s on line %d
38bool(false)
39bool(false)
40bool(false)
41bool(false)
42bool(false)
43