Re: Check if PCRE has UTF-8 support compiled in

From: Date: Thu, 28 Jun 2007 12:37:22 +0000
Subject: Re: Check if PCRE has UTF-8 support compiled in
References: 1 2  Groups: php.i18n 
Request: Send a blank email to php-i18n+get-1075@lists.php.net to get a copy of this message
Nuno Lopes, Thanks a lot! I was able to resolve the issue! Odd enough, POSIX named classes (eg [:alnum:] are not supported either when PCRE is not compiled with UTF-8 and Unicode support. Which is weird, because the manual states elsewise. For those of you interested to see the fix, please refer to: http://framework.zend.com/fisheye/browse/Zend_Framework/trunk/library/Zend/Filter/Alnum.php?r=5468 Nuno, thanks again! Best, -- Andries Seutens http://andries.systray.be Nuno Lopes schreef: > The first thing I would do is to convince those guys (RedHat) to > compile PCRE with UTF-8 and Unicode stuff support (that's 2 different > build options). They have probably forgot to include them. > Ok, so to detect if you have UTF-8 support.. uhm we could add a > function to do that (PCRE exports that information), but I think you > want something quicker than asking everybody to upgrade php :P You can > always try to match a simple thing and see if it returns an error or not. > e.g. if (!preg_match('/\pL/u', 'a')) die('bastard'); > > Nuno > > > ----- Original Message ----- From: "Andries Seutens" > <andries.seutens@skynet.be> > To: <php-i18n@lists.php.net> > Sent: Wednesday, June 27, 2007 6:36 PM > Subject: [PHP-I18N] Check if PCRE has UTF-8 support compiled in > > >> Dear all, >> >> In the Zend Framework we have written a filter to filter anything but >> alpha an numeric characters from a string. The regular expression for >> this filter looks like so: >> >> $result = preg_replace('/[^\p{L}\p{N}\s]/u', '', '!!testing123!!'); >> >> Apperently, on some systems like RHEL however, this regular >> expression seems to fail. The reason that it is failing for you >> appears to be that your PCRE does not have UTF-8 support compiled >> in? This is likely the result of the particular distribution not >> having used the --enable-utf8 option. >> >> What this means to us is that the class should become aware of >> whether such support is available, and act accordingly. >> >> My question to you guys is, how would such a check for support best >> be done? Perhaps detect the error condition, which would only occur >> in the event that the system does not have utf-8 support? But how >> (preferably without going down the dirty path .... )? >> >> Best regards, >> >> >> Andries Seutens >> http://andries.systray.be >> -- >> PHP Unicode & I18N Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.i18n (#1075) next »