<bdo id='Sjdfz'></bdo><ul id='Sjdfz'></ul>
    <legend id='Sjdfz'><style id='Sjdfz'><dir id='Sjdfz'><q id='Sjdfz'></q></dir></style></legend>

    1. <i id='Sjdfz'><tr id='Sjdfz'><dt id='Sjdfz'><q id='Sjdfz'><span id='Sjdfz'><b id='Sjdfz'><form id='Sjdfz'><ins id='Sjdfz'></ins><ul id='Sjdfz'></ul><sub id='Sjdfz'></sub></form><legend id='Sjdfz'></legend><bdo id='Sjdfz'><pre id='Sjdfz'><center id='Sjdfz'></center></pre></bdo></b><th id='Sjdfz'></th></span></q></dt></tr></i><div id='Sjdfz'><tfoot id='Sjdfz'></tfoot><dl id='Sjdfz'><fieldset id='Sjdfz'></fieldset></dl></div>

      <small id='Sjdfz'></small><noframes id='Sjdfz'>

      <tfoot id='Sjdfz'></tfoot>
    2. PHP 中的 preg_match 和 UTF-8

      时间:2023-09-22
        <tbody id='USKLQ'></tbody>
    3. <small id='USKLQ'></small><noframes id='USKLQ'>

        <tfoot id='USKLQ'></tfoot>

              <i id='USKLQ'><tr id='USKLQ'><dt id='USKLQ'><q id='USKLQ'><span id='USKLQ'><b id='USKLQ'><form id='USKLQ'><ins id='USKLQ'></ins><ul id='USKLQ'></ul><sub id='USKLQ'></sub></form><legend id='USKLQ'></legend><bdo id='USKLQ'><pre id='USKLQ'><center id='USKLQ'></center></pre></bdo></b><th id='USKLQ'></th></span></q></dt></tr></i><div id='USKLQ'><tfoot id='USKLQ'></tfoot><dl id='USKLQ'><fieldset id='USKLQ'></fieldset></dl></div>
                <bdo id='USKLQ'></bdo><ul id='USKLQ'></ul>
              • <legend id='USKLQ'><style id='USKLQ'><dir id='USKLQ'><q id='USKLQ'></q></dir></style></legend>
                本文介绍了PHP 中的 preg_match 和 UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试使用 preg_match<搜索 UTF8 编码的字符串/a>.

                I'm trying to search a UTF8-encoded string using preg_match.

                preg_match('/H/u', "xC2xA1Hola!", $a_matches, PREG_OFFSET_CAPTURE);
                echo $a_matches[0][1];
                

                这应该打印 1,因为H"在字符串¡Hola!"的索引 1 处.但它打印 2.所以它似乎没有将主题视为 UTF8 编码的字符串,即使我正在传递 "u" 修饰符.

                This should print 1, since "H" is at index 1 in the string "¡Hola!". But it prints 2. So it seems like it's not treating the subject as a UTF8-encoded string, even though I'm passing the "u" modifier in the regular expression.

                我的 php.ini 中有以下设置,并且其他 UTF8 函数正在运行:

                I have the following settings in my php.ini, and other UTF8 functions are working:

                mbstring.func_overload = 7
                mbstring.language = Neutral
                mbstring.internal_encoding = UTF-8
                mbstring.http_input = pass
                mbstring.http_output = pass
                mbstring.encoding_translation = Off
                

                有什么想法吗?

                推荐答案

                看起来这是一个功能",见http://bugs.php.net/bug.php?id=37391

                Looks like this is a "feature", see http://bugs.php.net/bug.php?id=37391

                'u' 开关只对 pcre 有意义,PHP 本身并不知道.

                'u' switch only makes sense for pcre, PHP itself is unaware of it.

                从 PHP 的角度来看,字符串是字节序列,返回字节偏移似乎是合乎逻辑的(我不是说正确").

                From PHP's point of view, strings are byte sequences and returning byte offset seems logical (i don't say "correct").

                这篇关于PHP 中的 preg_match 和 UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:PHP 字符串中的 Unicode 字符 下一篇:PHP:将 unicode 代码点转换为 UTF-8

                相关文章

                最新文章

                1. <small id='rWAQJ'></small><noframes id='rWAQJ'>

                2. <tfoot id='rWAQJ'></tfoot>

                  <legend id='rWAQJ'><style id='rWAQJ'><dir id='rWAQJ'><q id='rWAQJ'></q></dir></style></legend>

                    <bdo id='rWAQJ'></bdo><ul id='rWAQJ'></ul>
                3. <i id='rWAQJ'><tr id='rWAQJ'><dt id='rWAQJ'><q id='rWAQJ'><span id='rWAQJ'><b id='rWAQJ'><form id='rWAQJ'><ins id='rWAQJ'></ins><ul id='rWAQJ'></ul><sub id='rWAQJ'></sub></form><legend id='rWAQJ'></legend><bdo id='rWAQJ'><pre id='rWAQJ'><center id='rWAQJ'></center></pre></bdo></b><th id='rWAQJ'></th></span></q></dt></tr></i><div id='rWAQJ'><tfoot id='rWAQJ'></tfoot><dl id='rWAQJ'><fieldset id='rWAQJ'></fieldset></dl></div>