#38860 [Fbk->Opn]: preg_match returns wrong positions of matched substrings when UTF-8 is used

From: Date: Mon, 18 Sep 2006 15:29:09 +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-102338@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: Please download http://flybb.ru/pcre_bug.phps Previous Comments: ------------------------------------------------------------------------ [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 = "&#1087;&#1088;&#1080;&#1074;&#1077;&#1090; &#1072;&#1085;&#1076;&#1088;&#1077;&#1081;"; preg_match('/&#1072;&#1085;&#1076;&#1088;&#1077;&#1081;/u', $textUtf8, $matches, PREG_OFFSET_CAPTURE); print_r($matches); ?> </pre> Expected result: ---------------- Array ( [0] => Array ( [0] => &#1072;&#1085;&#1076;&#1088;&#1077;&#1081; [1] => 7 ) ) Actual result: -------------- Array ( [0] => Array ( [0] => &#1072;&#1085;&#1076;&#1088;&#1077;&#1081; [1] => 13 ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38860&edit=1

« previous php.bugs (#102338) next »