PHP PCRE(regex)不支持UTF-8? [英] PHP PCRE (regex) doesn't support UTF-8?

查看:114
本文介绍了PHP PCRE(regex)不支持UTF-8?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am attempting to run a regex on my site, and I am getting this response:

编译失败:支持\ P, \ p和\ X尚未在处编译 偏移量1

Compilation failed: support for \P, \p, and \X has not been compiled at offset 1

搜索了一段时间后,我发现我的服务器上的PCRE显然未启用UTF8,因此会引起问题.当我用pcretest -C SSH时,我得到了

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 6.6版本2006年2月6日

PCRE version 6.6 06-Feb-2006

编译时支持UTF-8否 Unicode属性支持换行符 字符为LF内部链接大小= 2 POSIX malloc阈值= 10
默认匹配限制= 10000000
默认递归深度限制= 10000000匹配递归使用堆栈

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.

人们告诉我可以打开UTF-8支持...帮助吗?

People are telling me that I can turn on UTF-8 support...help?

我是菜鸟.

推荐答案

有一个很好的教程,关于重建pcre的RPM

There's a good tutorial on rebuilding the RPM for pcre here.

如果您向下滚动到"Updated RPM file for ...",则只是希望它可以工作就可以找到一些预建的RPM(记住,完成后要重新启动Apache,而不仅仅是重新加载)

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).

tl; dr版本是:用--enable-utf8--enable-unicode-properties

The tl;dr version is: recompile pcre with --enable-utf8 and --enable-unicode-properties

这篇关于PHP PCRE(regex)不支持UTF-8?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆