|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-02-12 09:56 UTC] nikic@php.net
-Status: Open
+Status: Not a bug
[2019-02-12 09:56 UTC] nikic@php.net
[2019-02-12 10:03 UTC] nikic@php.net
-Summary: mbfl library bug
+Summary: mb_substr does not respect mb_substitution_character
-Status: Not a bug
+Status: Re-Opened
[2019-02-12 10:03 UTC] nikic@php.net
[2019-02-23 06:14 UTC] jhdxr@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 07:00:01 2025 UTC |
Description: ------------ Processing bad utf-16 strings leads to unexpected source data changes. Test script: --------------- <?php $bad_utf16be = pack("H*", "dc00dc00"); /* two 1 byte chars */ $good_utf16be = pack("H*", "d800dc00"); /* one 2 bytes char */ $utf16_string = $bad_utf16be . $good_utf16be; /* take second and third char */ $second = mb_substr($utf16_string, 1, 1, "UTF-16BE"); $third = mb_substr($utf16_string, 2, 1, "UTF-16BE"); echo "\nactual:\n"; echo "second UTF-16BE char: 0x". bin2hex($second) . PHP_EOL; echo "third UTF-16BE char: 0x". bin2hex($third) . PHP_EOL; echo "\nexpected:\n"; echo "second UTF-16BE char: 0xdc00" . PHP_EOL; echo "third UTF-16BE char: 0xd800dc00" . PHP_EOL; Expected result: ---------------- expected: second UTF-16BE char: 0xdc00 third UTF-16BE char: 0xd800dc00 Actual result: -------------- actual: second UTF-16BE char: 0x003f third UTF-16BE char: 0xd800dc00