ID: 42866 Comment by: claudiocherubino at gmail dot com Reported By: kraghuba at in dot ibm dot com Status: Open Bug Type: Strings related Operating System: linux,win xp PHP Version: 6CVS-2007-10-05 (snap) New Comment:
I tried fixing the bug, in my opinion a single line should be changed. Sorry, I don't know if this is the right place to post the patch. Here it is: Index: ext/standard/string.c =================================================================== RCS file: /repository/php-src/ext/standard/string.c,v retrieving revision 1.655 diff -u -r1.655 string.c --- ext/standard/string.c 7 Oct 2007 05:15:06 -0000 1.655 +++ ext/standard/string.c 15 Nov 2007 17:29:00 -0000 @@ -7802,7 +7802,7 @@ } if (p != (str.s + str_len * charsize)) { - add_next_index_zstrl(return_value, str_type, ZSTR(p), (str.s + str_len * charsize - p), 1); + add_next_index_zstrl(return_value, str_type, ZSTR(p), (str.s + str_len * charsize - p)/charsize, 1); } } /* }}} */ Previous Comments: ------------------------------------------------------------------------ [2007-10-05 11:20:59] kraghuba at in dot ibm dot com Description: ------------ str_split() returns extra charecter when given string is not mulitple of given length. for example if the given string size is 22 and split length is 5, then the last element of the returned array contains 5 or more than 5 chars, which is wrong. The last element of the return array should only contain 2 chars. This behavior is only noticed on PHP6 with UNICODE ON Reproduce code: --------------- <?php $str = 'Testing str_split()'; $split_length = 5; var_dump( str_split($str, $split_length) ); ?> Expected result: ---------------- array(4) { [0]=> unicode(5) "Testi" [1]=> unicode(5) "ng st" [2]=> unicode(5) "r_spl" [3]=> unicode(4) "it()" } Actual result: -------------- array(4) { [0]=> unicode(5) "Testi" [1]=> unicode(5) "ng st" [2]=> unicode(5) "r_spl" [3]=> unicode(8) "it()[EMAIL PROTECTED]@1" } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42866&edit=1