php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79787 mb_strimwidth does not trim string
Submitted: 2020-07-04 14:08 UTC Modified: -
From: x dot xiang at outlook dot com Assigned:
Status: Closed Package: mbstring related
PHP Version: Irrelevant OS: All
Private report: No CVE-ID: None
 [2020-07-04 14:08 UTC] 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

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-04 14:22 UTC] x dot xiang at outlook dot com
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
 [2020-07-08 09:23 UTC] nikic@php.net
Automatic comment on behalf of x.xiang@outlook.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=3d5de7d74660b1ba6ae92a91581f7a50573554dc
Log: Fix bug #79787
 [2020-07-08 09:23 UTC] nikic@php.net
-Status: Open +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC