Skip to content

Commit ed92f9e

Browse files
[Mbstring] fix mb_str_split() ignoring new-line characters
1 parent 7b4aab9 commit ed92f9e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Mbstring.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,14 @@ public static function mb_str_split($string, $split_length = 1, $encoding = null
545545
}
546546

547547
if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
548-
return preg_split("/(.{{$split_length}})/u", $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
548+
$rx = '/(';
549+
while (65535 < $split_length) {
550+
$rx .= '.{65535}';
551+
$split_length -= 65535;
552+
}
553+
$rx .= '.{'.$split_length.'})/us';
554+
555+
return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
549556
}
550557

551558
$result = array();

0 commit comments

Comments
 (0)