I have recently encountered this error:
PHP Warning: preg_match(): Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support at offset 0
And despite some of the suggested solutions I have found in various Drupal and MediaWiki forums, all of them related to older versions of ports.
The version of pcre I have installed is 7.8. as seen here:
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
But the curious thing is phpinfo(), told a different story.
Why was phpinfo() telling me the version of pcre was 5.0.13?
I checked various things like which libraries php was linked to, and sure enough it was in fact the libpcre that it should have been. After countless iterations of “let me tweak this Makefile and see if it makes a difference” and countless rebuilds of pcre and php, it occurred me, what about Apache? Now I’m not really sure why I this occurred to me, or why it did not occur to me earlier, perhaps it was a result of having felt I had already exhausted the rest of my options.
So I took a look at the Apache build config:
# cd /usr/ports/www/apache22 # make config
Apparently the pcre Apache is using is a bundled one, so I decided to change this to use devel/pcre, where I know UTF-8 support is enabled.
and proceeded to rebuild and reinstall the apache22 port.
After restarting apache, my first test was to inspect what phpinfo() was reporting.
Now phpinfo is agreeing with what I originally expected it to, the pcre port that is installed. I proceeded to test my php code with great success and have not seen the error since.
I encountered this on FreeBSD 7.0 , Apache 2.2.9, PHP 5.2.7, and pcre 7.8. But given the large number of seemingly unresolved threads I’ve encountered through google I expect that there are similar situations in other operating systems and software versions as well.