gpt4 book ai didi

utf-8 - PHP5.3 preg_match 与 Umlaute UTF-8 修饰符

转载 作者:行者123 更新时间:2023-12-02 00:44:24 26 4
gpt4 key购买 nike

以下命令在 PHP5.3.8 Lamp(Ubuntu 11.04)-服务器上返回 true,但在 PHP5.3.2 Lamp(Ubuntu 10.04.2 LTS)-服务器上返回 false。

<?php echo preg_match('/\w/u', 'ß'); ?>

我几乎更改了 php.ini 文件中的所有设置,但没有成功。我将系统区域设置更改为 en_US.UTF-8 并使其成为 PHP 的默认区域设置。另外我尝试了 de_DE.UTF-8-locale。

在这两种情况下,我都使用 ubuntu 提供的默认包。

是否有人有另一个想法,在不编译任何包的情况下更改什么,以便 PHP5.3.2 也将返回 true?

最佳答案

PHP 5.3.2 uses PCRE 8.00 while PHP 5.3.8 uses PCRE 8.11.change in PCRE 8.10是添加 PCRE_UCP option :

PCRE_UCP

This option changes the way PCRE processes \B, \b, \D, \d, \S, \s, \W, \w, and some of the POSIX character classes. By default, only ASCII characters are recognized, but if PCRE_UCP is set, Unicode properties are used instead to classify characters. More details are given in the section on generic character types in the pcrepattern page. If you set PCRE_UCP, matching one of the items it affects takes much longer. The option is available only if PCRE has been compiled with Unicode property support.

不幸的是,您无法使用 PHP 中的模式修饰符直接触发此选项。如果可用(PHP 5.3.4 及更高版本),它将由 uPCRE_UTF8 一起设置。

关于utf-8 - PHP5.3 preg_match 与 Umlaute UTF-8 修饰符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8915713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com