#37391 [NEW]: PREG_OFFSET_CAPTURE not UTF-8 aware when using u modifier

From: Date: Tue, 09 May 2006 22:57:49 +0000
Subject: #37391 [NEW]: PREG_OFFSET_CAPTURE not UTF-8 aware when using u modifier
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-96878@lists.php.net to get a copy of this message
From: mike at silverorange dot com Operating system: Linux PHP version: 5.1.4 PHP Bug Type: PCRE related Bug description: PREG_OFFSET_CAPTURE not UTF-8 aware when using u modifier Description: ------------ When using preg_match_all() with the PREG_OFFSET_CAPTURE flag, the returned match offsets are in octets rather than characters. PCRE is compiled with --enable-utf8 and I am using the u modifier in my regular expression. Reproduce code: --------------- <?php $matches = array(); $reg_exp = "/B/u"; // UTF8 represents A-euro-BC $string = "A\xe2\x82\xacBC"; preg_match_all($reg_exp, $string, $matches, PREG_OFFSET_CAPTURE); print_r($matches); ?> Expected result: ---------------- Array ( [0] => Array ( [0] => Array ( [0] => B [1] => 2 ) ) ) Actual result: -------------- Array ( [0] => Array ( [0] => Array ( [0] => B [1] => 4 ) ) ) -- Edit bug report at http://bugs.php.net/?id=37391&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37391&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37391&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37391&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=37391&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=37391&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=37391&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=37391&r=needscript Try newer version: http://bugs.php.net/fix.php?id=37391&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=37391&r=support Expected behavior: http://bugs.php.net/fix.php?id=37391&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=37391&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=37391&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=37391&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37391&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=37391&r=dst IIS Stability: http://bugs.php.net/fix.php?id=37391&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=37391&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=37391&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=37391&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=37391&r=mysqlcfg

« previous php.bugs (#96878) next »