php-src/ext/mbstring/tests/mb_substitute_character_variation2.phpt
Alex Dowad 3c73225125 New internal interface for fast text conversion in mbstring
When converting text to/from wchars, mbstring makes one function call
for each and every byte or wchar to be converted. Typically, each of
these conversion functions contains a state machine, and its state has
to be restored and then saved for every single one of these calls.
It doesn't take much to see that this is grossly inefficient.

Instead of converting one byte or wchar on each call, the new
conversion functions will either fill up or drain a whole buffer of
wchars on each call. In benchmarks, this is about 3-10× faster.

Adding the new, faster conversion functions for all supported legacy
text encodings still needs some work. Also, all the code which uses
the old-style conversion functions needs to be converted to use the
new ones. After that, the old code can be dropped. (The mailparse
extension will also have to be fixed up so it will still compile.)
2021-12-21 08:33:11 +02:00

29 lines
964 B
PHP

--TEST--
Test mb_substitute_character() function : variation unmappable out char for convert encoding
--EXTENSIONS--
mbstring
--FILE--
<?php
echo "*** Testing mb_substitute_character() : variation ***\n";
//japanese utf-8
$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI');
//output the default which is ? in ISO-8859-1, x3f
var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
mb_substitute_character(66); //'B' in ISO-8859-1, x42
var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
mb_substitute_character("none"); //no substitution
var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
mb_substitute_character(280); //not valid in ISO-8859-1
var_dump(bin2hex(mb_convert_encoding($string_mb, "ISO-8859-1", "UTF-8")));
?>
--EXPECT--
*** Testing mb_substitute_character() : variation ***
string(14) "3f3f3f3f3f3f3f"
string(14) "42424242424242"
string(0) ""
string(14) "3f3f3f3f3f3f3f"