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

From: Date: Sat, 04 Jul 2020 14:08:02 +0000
Subject: Bug #79787 [NEW]: mb_strimwidth does not trim string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227811@lists.php.net to get a copy of this message
From: x dot xiang at outlook dot com Operating system: All PHP version: Irrelevant Package: mbstring related Bug Type: Bug Bug description:mb_strimwidth does not trim string 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 bug report at https://bugs.php.net/bug.php?id=79787&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79787&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79787&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79787&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79787&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79787&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79787&r=support Expected behavior: https://bugs.php.net/fix.php?id=79787&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79787&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79787&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79787&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79787&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79787&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79787&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79787&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79787&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79787&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79787&r=mysqlcfg

« previous php.bugs (#227811) next »