ID: 49354 Updated by: moriyo...@php.net Reported By: mk at zigamorph dot se -Status: Assigned +Status: Closed Bug Type: mbstring related Operating System: Linux PHP Version: 5.2.10 Assigned To: moriyoshi New Comment:
This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2009-09-23 15:22:47] s...@php.net Automatic comment from SVN on behalf of moriyoshi Revision: http://svn.php.net/viewvc/?view=revision&revision=288613 Log: - Fixed bug #49354 (mb_strcut() cuts wrong length when offset is within a multibyte character). (This bug was introduced by the commit by r202895. Please double-check the specification of the function you are going to *fix*.) ------------------------------------------------------------------------ [2009-08-25 07:33:02] mk at zigamorph dot se Description: ------------ When you use mb_strcut with an offset and this offset happens to fall within a multibyte (utf-8) character mb_strcut moves the start point of the string as to not break a multibyte character. As an undesirable side effect it strips one or more bytes from the end of the cut string. Reproduce code: --------------- $crap = 'AåBäCöDü' /* in utf-8 */ echo mb_strcut($crap, 0, 100, 'UTF-8')."\n"; /* 'AåBäCöDü' as 100 is more than strlen */ echo mb_strcut($crap, 1, 100, 'UTF-8')."\n"; /* 'åBäCöDü' as 100 is more than strlen and we're offset 1 byte */ echo mb_strcut($crap, 2, 100, 'UTF-8')."\n"; /* 'åBäCöD' */ Expected result: ---------------- $crap = 'AåBäCöDü' /* in utf-8 */ echo mb_strcut($crap, 0, 100, 'UTF-8')."\n"; /* 'AåBäCöDü' as 100 is more than strlen */ echo mb_strcut($crap, 1, 100, 'UTF-8')."\n"; /* 'åBäCöDü' as 100 is more than strlen and we're offset 1 byte */ echo mb_strcut($crap, 2, 100, 'UTF-8')."\n"; /* either 'åBäCöDü' or 'BäCöDü' */ ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49354&edit=1