PHP PCRE(正则表达式)不支持 UTF-8?
我正在尝试在我的网站上运行正则表达式,并且收到以下响应:
编译失败:支持\P, \p 和 \X 尚未编译 偏移1
在谷歌搜索了一下之后,我发现我的服务器上的 PCRE 显然没有启用 UTF8,因此导致了问题。当我使用 pcretest -CI 进行 ssh 时,得到
PCRE 版本 6.6 2006 年 2 月 6 日
编译时支持 UTF-8 否 Unicode 属性支持换行符 字符为 LF 内部链接大小 = 2 POSIX malloc 阈值 = 10
默认匹配限制 = 10000000
默认递归深度限制 = 10000000 匹配递归使用堆栈
当我执行 yum update pcre 时,它告诉我没有任何可更新的内容。
人们告诉我可以打开 UTF-8 支持...有帮助吗?
我是一个菜鸟。
I am attempting to run a regex on my site, and I am getting this response:
Compilation failed: support for \P,
\p, and \X has not been compiled at
offset 1
After googling for a bit, I've found that apparently my PCRE on my server is not UTF8 enabled, and is therefore causing problems. When I ssh with pcretest -C I get
PCRE version 6.6 06-Feb-2006
Compiled with UTF-8 support No
Unicode properties support Newline
character is LF Internal link size =
2 POSIX malloc threshold = 10
Default match limit = 10000000
Default recursion depth limit =
10000000 Match recursion uses stack
When I do yum update pcre it tells me that there isn't anything to update.
People are telling me that I can turn on UTF-8 support...help?
I am a noob.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有一个关于为 pcre 重建 RPM 的好教程 此处。
如果你向下滚动到“更新的 RPM 文件...”,如果你只是想让它工作的话,你会发现一些预构建的 RPM(记住在完成后重新启动 Apache,而不仅仅是优雅地重新加载)。
tl;dr 版本是:使用
--enable-utf8
和--enable-unicode-properties
重新编译 pcreThere's a good tutorial on rebuilding the RPM for pcre here.
If you scroll down to "Updated RPM file for..." you'll find some pre-built RPM's if you just want it to work (remember to restart Apache after you're done, not just a graceful reload).
The tl;dr version is: recompile pcre with
--enable-utf8
and--enable-unicode-properties
Yum 现在应该在其存储库中找到 PCRE 的
v6.6.6.el5_6.1
,因此在 Centos 5 上执行yum update pcre
解决了我的问题。Yum should now find
v6.6.6.el5_6.1
of PCRE in its repositories, so performing ayum update pcre
resolved the issue for me on Centos 5.PHP 不使用“pcre”应用程序/包。 PCRE 支持内置于 PHP 库中。您收到的错误告诉您您的 PHP 库未使用 PCRE UTF-8 支持进行编译。
您需要使用使用正确的 UTF-8 选项构建的正确 PCRE 静态库重新编译 PHP。
PHP doesn't use the "pcre" application/package. PCRE support is built in to the PHP libraries. The error you're getting is telling you that your PHP libraries were not compiled with PCRE UTF-8 support.
You'll need to recompile PHP with the proper PCRE static library built with the proper UTF-8 option.