1757b php5-pcre utf-8 problems - The FreeBSD Forums
The FreeBSD Forums  

Go Back   The FreeBSD Forums > Ports & Packages > Installation and Maintenance of FreeBSD Ports or Packages

Installation and Maintenance of FreeBSD Ports or Packages Installing and maintaining the FreeBSD Ports Collection or FreeBSD Packages (i.e. third party software).

Reply
 
Thread Tools Display Modes
  #1  
Old November 29th, 2008, 19:22
saiman saiman is offline
Junior Member
 
Join Date: Nov 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default php5-pcre utf-8 problems

Hi all,
I'm trying to get php5-pcre working with utf-8 support. Here is the test case:

<?php
if (@preg_match('/\pL/u', 'a') == 1) {
echo "PCRE unicode support is turned on.\n";
} else {
echo "PCRE unicode support is turned off.\n";
}
?>

And the result is "PCRE unicode support is turned off". I have the following installed:

# pkg_info |grep pcre
pcre-7.8 Perl Compatible Regular Expressions library
php5-pcre-5.2.6_2 The pcre shared extension for php

And this is the output from pcretest -C:

PCRE version 7.8 2008-09-05
Compiled with
UTF-8 support
Unicode properties support
Newline sequence is LF
\R matches all Unicode newlines
Internal link size = 2
POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit = 10000000
Match recursion uses stack

I'm using FreeBSD 6 stable. This is the output from uname:

FreeBSD xxxx 6.3-STABLE FreeBSD 6.3-STABLE #2: Mon Aug 4 16:50:44 EEST 2008

I tried to reinstall pcre and php5-pcre, but the result is the same. Any suggestions are welcome.

Tanks in advance !
Reply With Quote
  #2  
Old November 30th, 2008, 02:17
aragon aragon is offline
Giant Locked
 
Join Date: Nov 2008
Location: Cape Town, South Africa
Posts: 2,031
Thanks: 68
Thanked 253 Times in 203 Posts
Default

I think your test case should be:

if (@preg_match('/\p{L}/u', 'a') == 1) {
Reply With Quote
  #3  
Old November 30th, 2008, 10:22
saiman saiman is offline
Junior Member
 
Join Date: Nov 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The test case is changed, but the result is still:

"PCRE unicode support is turned off."
Reply With Quote
  #4  
Old November 30th, 2008, 22:36
aragon aragon is offline
Giant Locked
 
Join Date: Nov 2008
Location: Cape Town, South Africa
Posts: 2,031
Thanks: 68
Thanked 253 Times in 203 Posts
Default

That is strange. Did you install from ports? Mine works:

Code:
$ php -q
<?
if (@preg_match('/\p{L}/u', 'a') == 1) {
echo "PCRE unicode support is turned on.\n";
} else {
echo "PCRE unicode support is turned off.\n";
}
?> 
PCRE unicode support is turned on.

$ pkg_info -xI php
php5-5.2.6          PHP Scripting Language
php5-ctype-5.2.6    The ctype shared extension for php
php5-dom-5.2.6      The dom shared extension for php
php5-gettext-5.2.6_1 The gettext shared extension for php
php5-mbstring-5.2.6 The mbstring shared extension for php
php5-mhash-5.2.6    The mhash shared extension for php
php5-mysql-5.2.6    The mysql shared extension for php
php5-openssl-5.2.6_2 The openssl shared extension for php
php5-pcre-5.2.6     The pcre shared extension for php
php5-pdo-5.2.6      The pdo shared extension for php
php5-pdo_mysql-5.2.6 The pdo_mysql shared extension for php
php5-pdo_sqlite-5.2.6_1 The pdo_sqlite shared extension for php
php5-session-5.2.6  The session shared extension for php
php5-simplexml-5.2.6 The simplexml shared extension for php
php5-spl-5.2.6      The spl shared extension for php
php5-wddx-5.2.6     The wddx shared extension for php
php5-xml-5.2.6      The xml shared extension for php
php5-xmlreader-5.2.6_1 The xmlreader shared extension for php
php5-xmlrpc-5.2.6_2 The xmlrpc shared extension for php
php5-xsl-5.2.6      The xsl shared extension for php
php5-zlib-5.2.6     The zlib shared extension for php
Reply With Quote
  #5  
Old December 2nd, 2008, 11:34
saiman saiman is offline
Junior Member
 
Join Date: Nov 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Did you install from ports?
Yes. I used ports.
Reply With Quote
  #6  
Old December 2nd, 2008, 11:46
kamikaze's Avatar
kamikaze kamikaze is offline
Member
 
Join Date: Nov 2008
Location: /earth/europe/germany
Posts: 366
Thanks: 6
Thanked 66 Times in 45 Posts
Default

Maybe you have to set a locale with UTF-8.
__________________
sysutils/bsdadminscripts: binary package maintenance, library integrity checking, ...
sysutils/automounter: amd(8) based automounting without HAL
contact: kamikaze@bsdforen.de

Disclaimer: My posts represent my perception. Errors and incompleteness are to be expected, I deny any responsibility to know everything.
Reply With Quote
  #7  
Old December 2nd, 2008, 13:58
saiman saiman is offline
Junior Member
 
Join Date: Nov 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I modified /etc/login.conf inserting the following line in default section:

Code:
:charset=UTF-8:\
Then rebuild with:

Code:
cap_mkdb /etc/login.conf
After that i recompiled the php with:

Code:
portupgrade -Df php5*
And the result is still the same:

Code:
# php test.php 
PCRE unicode support is turned off.
Reply With Quote
  #8  
Old December 2nd, 2008, 15:34
aragon aragon is offline
Giant Locked
 
Join Date: Nov 2008
Location: Cape Town, South Africa
Posts: 2,031
Thanks: 68
Thanked 253 Times in 203 Posts
Default

Try install the pcre module from a package build.
Reply With Quote
  #9  
Old December 2nd, 2008, 16:43
saiman saiman is offline
Junior Member
 
Join Date: Nov 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Obviously the problem it's not into the port, because with the package the result is the same. It's something else ..
Reply With Quote
  #10  
Old December 3rd, 2008, 05:30
Mel_Flynn Mel_Flynn is offline
Member
 
Join Date: Nov 2008
Location: Drachten, Netherlands
Posts: 379
Thanks: 7
Thanked 74 Times in 57 Posts
Default

Could you show:
Code:
make -C /usr/ports/lang/php5 showconfig
Reply With Quote
  #11  
Old December 3rd, 2008, 09:49
saiman saiman is offline
Junior Member
 
Join Date: Nov 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
# make -C /usr/ports/lang/php5 showconfig
===> The following configuration options are available for php5-5.2.6_2:
     CLI=on "Build CLI version"
     CGI=off "Build CGI version"
     APACHE=on "Build Apache module"
     DEBUG=off "Enable debug"
     SUHOSIN=on "Enable Suhosin protection system (not for jails)"
     MULTIBYTE=on "Enable zend multibyte support"
     IPV6=off "Enable ipv6 support"
     MAILHEAD=on "Enable mail header patch"
     REDIRECT=off "Enable force-cgi-redirect support (CGI only)"
     DISCARD=off "Enable discard-path support (CGI only)"
     FASTCGI=on "Enable fastcgi support (CGI only)"
     PATHINFO=on "Enable path-info-check support (CGI only)"
===> Use 'make config' to modify these settings
Reply With Quote
  #12  
Old December 4th, 2008, 04:38
dave's Avatar
dave dave is offline
Member
 
Join Date: Nov 2008
Posts: 300
Thanks: 37
Thanked 18 Times in 18 Posts
Default

Perhaps this is a silly question - but... (if you are using mod_php5) did you restart apache after rebuilding PCRE extension?
Reply With Quote
  #13  
Old December 4th, 2008, 06:20
Mel_Flynn Mel_Flynn is offline
Member
 
Join Date: Nov 2008
Location: Drachten, Netherlands
Posts: 379
Thanks: 7
Thanked 74 Times in 57 Posts
Default

Well, the usual suspect, multibyte zend is on. Next up: mbstring extension is loaded? And the internal encoding:
Code:
php -i |grep internal_encoding
Reply With Quote
  #14  
Old December 4th, 2008, 09:53
saiman saiman is offline
Junior Member
 
Join Date: Nov 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
did you restart apache after rebuilding PCRE extension?
Yes I did.

Code:
php -i |grep internal_encoding
iconv.internal_encoding => ISO-8859-1 => ISO-8859-1
mbstring.internal_encoding => ISO-8859-1 => no value
Reply With Quote
  #15  
Old November 4th, 2011, 16:58
wuciwug wuciwug is offline
Junior Member
 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Solved (for me at least!)

I know its old - Google doesn't care though! Try running your test script on the command line i.e php xxx.php and see if that works. I found with apache-2.2.21 and php5-5.3.8 I needed to add
Code:
AddDefaultCharset utf8 to httpd.conf
to httpd.conf.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Problems installing Unreal Tournament phreud Installation and Maintenance of FreeBSD Ports or Packages 8 January 17th, 2011 18:50
lcUTF8.c error when installing php5-extensions? Lobster Installation and Maintenance of FreeBSD Ports or Packages 2 November 23rd, 2008 11:08
Some problems with CARP sibdoma Firewalls 5 November 20th, 2008 12:18
problems setting up PolicyKit in FreeBSD 6.3 kantor General 5 November 18th, 2008 17:31
Problems vermaden Feedback 5 November 16th, 2008 22:36


All times are GMT +1. The time now is 07:03.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
The mark FreeBSD is a registered trademark of The FreeBSD Foundation and is used by The FreeBSD Project with the permission of The FreeBSD Foundation.
Web protection and acceleration provided by CloudFlare
0