#19346 [Opn->Bgs]: preg_match() does not work for UTF-8

From: Date: Tue, 10 Sep 2002 23:47:30 +0000
Subject: #19346 [Opn->Bgs]: preg_match() does not work for UTF-8
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18992@lists.php.net to get a copy of this message
ID: 19346 Updated by: wez@php.net Reported By: gamid@isayev.net -Status: Open +Status: Bogus Bug Type: PCRE related Operating System: Mandrake 8.1 PHP Version: 4.3.2-dev New Comment: The manual says: u (PCRE_UTF8) This modifier turns on additional functionality of PCRE that is incompatible with Perl. Pattern strings are treated as UTF-8. This modifier is available from PHP 4.1.0 or greater on Unix and from PHP 4.2.3 on win32. So, it's only the pattern string that is treated as utf-8; the subject string is still treated as a sequence of ascii bytes. I have to admit that I thought that the subject would be treated as utf-8 too, but that is not the case. So, this is "bogus" (it sounds so harsh) as far as PHP is concerned, although this is a valid feature request; it should be taken up with the pcre library people. Previous Comments: ------------------------------------------------------------------------ [2002-09-10 17:31:33] gamid@isayev.net BTW, it also does not work in PHP 4.3.2-dev, PHP: 20020307 PHP Extension: 20020429 Zend Extension: 20020903 ------------------------------------------------------------------------ [2002-09-10 17:30:08] gamid@isayev.net <? $name = "Test".utf8_encode("\xDC");; echo "name = '$name'<BR>\n"; echo preg_match("/^[[:alpha:]]+$/u", $name); echo "<BR>\n"; ?> The above snippet does not produce expected result. According to documentation, preg_match() should return a true value, but it returns false. It looks as modifier 'u' does not work as it is described in the manual ( http://www.php.net/manual/en/pcre.pattern.modifiers.php ). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19346&edit=1

« previous php.bugs (#18992) next »