Bug #79787 [PATCH]: mb_strimwidth does not trim string

From: Date: Sat, 04 Jul 2020 14:22:12 +0000
Subject: Bug #79787 [PATCH]: mb_strimwidth does not trim string
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227812@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79787&edit=1 ID: 79787 Patch added by: x.xiang@outlook.com Reported by: x dot xiang at outlook dot com Summary: mb_strimwidth does not trim string Status: Open Type: Bug Package: mbstring related Operating System: All PHP Version: Irrelevant Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: Fix bug #79787 : mb_strimwidth does not trim string On GitHub: https://github.com/php/php-src/pull/5807 Patch: https://github.com/php/php-src/pull/5807.patch Previous Comments: ------------------------------------------------------------------------ [2020-07-04 14:08:02] x dot xiang at outlook dot com Description: ------------ When the string end with full-width character and its width is one greater than the desired trimming width,trimmaker is alse a half-width character, which will cause mb_strimwidth not to trim. Affects all stable versions of PHP. Test script: --------------- <?php echo mb_strimwidth("一二三", 0, 4, '.', 'UTF-8')."\n"; echo mb_strimwidth("一二三", 0, 5, '.', 'UTF-8')."\n"; echo mb_strimwidth("一二三", 0, 6, '.', 'UTF-8')."\n"; echo mb_strimwidth("abcdef", 0, 4, '.', 'UTF-8')."\n"; echo mb_strimwidth("abcdef", 0, 5, '.', 'UTF-8')."\n"; echo mb_strimwidth("abcdef", 0, 6, '.', 'UTF-8')."\n"; Expected result: ---------------- 一. 一二. 一二三 abc. abcd. abcdef Actual result: -------------- 一. 一二三 一二三 abc. abcd. abcdef ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79787&edit=1

« previous php.bugs (#227812) next »