#38860 [Fbk->Opn]: preg_match returns wrong positions of matched substrings when UTF-8 is used
| From: | me at andr dot biz | Date: | Mon, 18 Sep 2006 15:13:07 +0000 |
| Subject: | #38860 [Fbk->Opn]: preg_match returns wrong positions of matched substrings when UTF-8 is used | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-102335@lists.php.net to get a copy of this message | ||
ID: 38860
User updated by: me at andr dot biz
Reported By: me at andr dot biz
-Status: Feedback
+Status: Open
Bug Type: PCRE related
Operating System: freebsd 6.1
PHP Version: 4.4.4
New Comment:
I tried this:
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
It return the same (wrong) result.
Previous Comments:
------------------------------------------------------------------------
[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