xref: /PHP-7.4/ext/mbstring/tests/bug69079.phpt (revision 782352c5)
1--TEST--
2Bug #69079 (enhancement for mb_substitute_character)
3--SKIPIF--
4<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5--FILE--
6<?php
7
8mb_internal_encoding('UTF-8');
9var_dump(mb_substitute_character(0x1F600));
10var_dump(bin2hex(mb_scrub("\xff")));
11mb_substitute_character(0x3f); // Reset to '?', as the next call will fail
12var_dump(mb_substitute_character(0xD800)); // Surrogate (illegal)
13var_dump(bin2hex(mb_scrub("\xff")));
14
15mb_internal_encoding('EUC-JP-2004');
16
17mb_substitute_character(0x63); // Reset to '?', as the next call will fail
18mb_substitute_character(0x8fa1ef); // EUC-JP-2004 encoding of U+50AA (illegal)
19var_dump(bin2hex(mb_scrub("\x8d")));
20
21mb_substitute_character(0x50aa);
22var_dump(bin2hex(mb_scrub("\x8d")));
23
24?>
25--EXPECTF--
26bool(true)
27string(8) "f09f9880"
28
29Warning: mb_substitute_character(): Unknown character in %s on line %d
30bool(false)
31string(2) "3f"
32
33Warning: mb_substitute_character(): Unknown character in %s on line %d
34string(2) "63"
35string(6) "8fa1ef"
36