#38860 [Opn->Bgs]: preg_match returns wrong positions of matched substrings when UTF-8 is used
ID: 38860
Updated by: tony2001@php.net
Reported By: me at andr dot biz
-Status: Open
+Status: Bogus
Bug Type: PCRE related
Operating System: freebsd 6.1
PHP Version: 4.4.4
New Comment:
Not PHP problem.
Please report it to PCRE lib developers.
Previous Comments:
------------------------------------------------------------------------
[2006-09-18 15:29:08] me at andr dot biz
Please download
http://flybb.ru/pcre_bug.phps
------------------------------------------------------------------------
[2006-09-18 15:22:55] tony2001@php.net
Please upload the reproduce code somewhere in the net and paste the URL
here.
------------------------------------------------------------------------
[2006-09-18 15:13:07] me at andr dot biz
I tried this:
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
It return the same (wrong) result.
------------------------------------------------------------------------
[2006-09-17 16:23:26] tony2001@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
------------------------------------------------------------------------
[2006-09-17 14:29:47] me at andr dot biz
Description:
------------
/*Guys! Your bugtracking software hase problems with cyrillic symbols.
I encoded all my words in example into HTML-entities. Please decode
them to UTF-8 before reproducing */
It processes UTF-8 strings incorrectly.
Firstly, please see the article:http://www.phpwact.org/php/i18n/utf-8
This article has so many described PHP bugst related to UTF-8. I think
that ALL theese bugs must be fixed ASAP.
Reproduce code:
---------------
<pre>
<?php
if (!setlocale(LC_ALL,"ru_RU.UTF-8")) die('error');
$textUtf8 = "привет
андрей";
preg_match('/андрей/u',
$textUtf8,
$matches, PREG_OFFSET_CAPTURE);
print_r($matches);
?>
</pre>
Expected result:
----------------
Array
(
[0] => Array
(
[0] => андрей
[1] => 7
)
)
Actual result:
--------------
Array
(
[0] => Array
(
[0] => андрей
[1] => 13
)
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=38860&edit=1
Thread (6 messages)