PHP PCRE(正则表达式)不支持 UTF-8?

发布于 2024-08-18 18:56:05 字数 497 浏览 5 评论 0原文

我正在尝试在我的网站上运行正则表达式,并且收到以下响应:

编译失败:支持\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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

分分钟 2024-08-25 18:56:05

有一个关于为 pcre 重建 RPM 的好教程 此处

如果你向下滚动到“更新的 RPM 文件...”,如果你只是想让它工作的话,你会发现一些预构建的 RPM(记住在完成后重新启动 Apache,而不仅仅是优雅地重新加载)。

tl;dr 版本是:使用 --enable-utf8--enable-unicode-properties 重新编译 pcre

There'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

与之呼应 2024-08-25 18:56:05

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 a yum update pcre resolved the issue for me on Centos 5.

時窥 2024-08-25 18:56:05

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文