mirror of
https://github.com/php/php-src.git
synced 2025-08-18 15:08:55 +02:00

`mb_encode_numericentity()` and `mb_decode_numericentity()` accepted arbitrary zvals as `$convmap`, but ignored anything else than arrays. This appears to be an unresolved relict of their ZPP conversion for PHP 5.3[1]. We now expect an array in the first place. We also expect `count($convmap)` to be a multiple of four (else we throw a `ValueError`), and do no longer special case empty `$convmap`. [1] <http://git.php.net/?p=php-src.git;a=commit;h=1c77f594294aee9d60e7309279c616c01c39ba9d>
34 lines
2.8 KiB
PHP
34 lines
2.8 KiB
PHP
--TEST--
|
|
Test mb_encode_numericentity() function : Convert UTF-8 to HTML-Entities
|
|
--SKIPIF--
|
|
<?php
|
|
if (!extension_loaded('mbstring')) die('skip mbstring not enabled');
|
|
function_exists('mb_encode_mimeheader') or die("skip mb_encode_mimeheader() is not available in this build");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
$str1 = '¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ';
|
|
$str2 = 'ƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦';
|
|
$convmap = array(0x0, 0x2FFFF, 0, 0xFFFF);
|
|
echo mb_encode_numericentity($str1, $convmap, "UTF-8")."\n";
|
|
echo mb_encode_numericentity($str2, $convmap, "UTF-8")."\n";
|
|
|
|
$convmap = array(0xFF, 0x2FFFF, 0, 0xFFFF);
|
|
echo mb_encode_numericentity('aŒbœcŠdše€fg', $convmap, "UTF-8")."\n";
|
|
|
|
$convmap = [];
|
|
echo mb_encode_numericentity('föo', $convmap, "UTF-8")."\n";
|
|
|
|
$convmap = array(0xFF, 0x2FFFF, 0); // 3 elements
|
|
try {
|
|
echo mb_encode_numericentity('aŒbœcŠdše€fg', $convmap, "UTF-8")."\n";
|
|
} catch (ValueError $ex) {
|
|
echo $ex->getMessage()."\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ
|
|
ƒΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρςστυφχψωϑϒϖ•…′″‾⁄℘ℑℜ™ℵ←↑→↓↔↵⇐⇑⇒⇓⇔∀∂∃∅∇∈∉∋∏∑−∗√∝∞∠∧∨∩∪∫∴∼≅≈≠≡≤≥⊂⊃⊄⊆⊇⊕⊗⊥⋅⌈⌉⌊⌋〈〉◊♠♣♥♦
|
|
aŒbœcŠdše€fg
|
|
föo
|
|
count($convmap) must be a multiple of 4
|