From: thunder013 at yopmail dot com
Operating system: Linux *AND* Windows
PHP version: 5.2.6
PHP Bug Type: PCRE related
Bug description: preg_split don't split correctly the sequence "\n\t" with the
u modifier
Description:
------------
I want to use preg_split with the u modifier to split a UTF-8 string by
each character, like that: preg_split('//u', $txt, -1,
PREG_SPLIT_NO_EMPTY);
It works fine, however, there is a bug when the string contains the
sequence "\n\t" (0x0A09 in hex): the two characters are NOT splitted (see
the example attached).
Note that this bug isn't present when preg_split is used whithout the u
modifier.
This bug was reported previously here for version 5.2.4:
http://bugs.php.net/bug.php?id=42737, but netherless is *still* present in
version 5.2.5 and 5.2.6!
Reproduce code:
---------------
<?
$txt = "abc\n\txyz!";
$tab = preg_split('//u', $txt, -1, PREG_SPLIT_NO_EMPTY);
print_r($tab);
echo '$tab[3]: len = ', strlen($tab[3]), ', hex = ',
bin2hex($tab[3]), "\n";
?>
Expected result:
----------------
Array
(
[0] => a
[1] => b
[2] => c
[3] =>
[4] =>
[5] => x
[6] => y
[7] => z
[8] => !
)
$tab[3]: len = 1, hex = 0a
Actual result:
--------------
$ php test.php
Array
(
[0] => a
[1] => b
[2] => c
[3] =>
[4] => x
[5] => y
[6] => z
[7] => !
)
$tab[3]: len = 2, hex = 0a09
--
Edit bug report at http://bugs.php.net/?id=45850&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=45850&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=45850&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=45850&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45850&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=45850&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45850&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45850&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45850&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45850&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45850&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=45850&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=45850&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45850&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45850&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45850&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45850&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45850&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45850&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45850&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45850&r=mysqlcfg