ID: 49354 Updated by: [email protected] Reported By: mk at zigamorph dot se -Status: Open +Status: Assigned Bug Type: mbstring related Operating System: Linux PHP Version: 5.2.10 -Assigned To: +Assigned To: moriyoshi
Previous Comments: ------------------------------------------------------------------------ [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
