Detect if PCRE was built without the --enable-unicode-properties or --enable-utf8 configuration switches

前端 未结 2 1810
悲&欢浪女
悲&欢浪女 2020-12-17 15:30

I\'ve a PHP library that uses a number of regular expressions featuring the \\P expressions for multibyte strings, e.g.

((((?:\\P{M}\\p{M}*)+?)|         


        
2条回答
  •  一向
    一向 (楼主)
    2020-12-17 16:09

    While comments suggest checking for PREG_BAD_UTF8_ERROR the PHP source http://lxr.php.net/xref/PHP_5_6/ext/pcre/php_pcre.c#141 suggests this constant is always available if PCRE is. Indeed it seems --enable-unicode-properties is a PCRE lib switch and is simply not exposed by PHP. The only thing I can imagine is running a simple regexp once with warning supressed...

提交回复
热议问题