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

        <tfoot id='cuX6V'></tfoot>
      1. <small id='cuX6V'></small><noframes id='cuX6V'>

        PHP 多字节 str_replace?

        时间:2023-05-21

        1. <legend id='zR6jp'><style id='zR6jp'><dir id='zR6jp'><q id='zR6jp'></q></dir></style></legend>
            <tbody id='zR6jp'></tbody>
            <bdo id='zR6jp'></bdo><ul id='zR6jp'></ul>
            <tfoot id='zR6jp'></tfoot>
            <i id='zR6jp'><tr id='zR6jp'><dt id='zR6jp'><q id='zR6jp'><span id='zR6jp'><b id='zR6jp'><form id='zR6jp'><ins id='zR6jp'></ins><ul id='zR6jp'></ul><sub id='zR6jp'></sub></form><legend id='zR6jp'></legend><bdo id='zR6jp'><pre id='zR6jp'><center id='zR6jp'></center></pre></bdo></b><th id='zR6jp'></th></span></q></dt></tr></i><div id='zR6jp'><tfoot id='zR6jp'></tfoot><dl id='zR6jp'><fieldset id='zR6jp'></fieldset></dl></div>
          • <small id='zR6jp'></small><noframes id='zR6jp'>

                • 本文介绍了PHP 多字节 str_replace?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试在 PHP 中进行重音字符替换,但得到的结果很奇怪,我猜是因为我使用的是 UTF-8 字符串,而 str_replace 无法正确处理多字节字符串..

                  I'm trying to do accented character replacement in PHP but get funky results, my guess being because i'm using a UTF-8 string and str_replace can't properly handle multi-byte strings..

                  $accents_search     = array('á','à','â','ã','ª','ä','å','Á','À','Â','Ã','Ä','é','è',
                  'ê','ë','É','È','Ê','Ë','í','ì','î','ï','Í','Ì','Î','Ï','œ','ò','ó','ô','õ','º','ø',
                  'Ø','Ó','Ò','Ô','Õ','ú','ù','û','Ú','Ù','Û','ç','Ç','Ñ','ñ'); 
                  
                  $accents_replace    = array('a','a','a','a','a','a','a','A','A','A','A','A','e','e',
                  'e','e','E','E','E','E','i','i','i','i','I','I','I','I','oe','o','o','o','o','o','o',
                  'O','O','O','O','O','u','u','u','U','U','U','c','C','N','n'); 
                  
                  $str = str_replace($accents_search, $accents_replace, $str);
                  

                  我得到的结果:

                  Ørjan Nilsen -> �orjan Nilsen
                  

                  预期结果:

                  Ørjan Nilsen -> Orjan Nilsen
                  

                  我的内部字符处理程序设置为 UTF-8(根据 mb_internal_encoding()),$str 的值也是 UTF-8,所以据我所知,所有涉及的字符串都是 UTF-8.str_replace() 是否检测字符集并正确使用它们?

                  I've got my internal character handler set to UTF-8 (according to mb_internal_encoding()), also the value of $str is UTF-8, so from what I can tell, all the strings involved are UTF-8. Does str_replace() detect char sets and use them properly?

                  推荐答案

                  看起来字符串没有被替换,因为你的输入编码和文件编码不匹配.

                  Looks like the string was not replaced because your input encoding and the file encoding mismatch.

                  这篇关于PHP 多字节 str_replace?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP 从数字字符串中删除逗号 下一篇:在文件中查找和替换

                  相关文章

                  最新文章

                  • <bdo id='vNBnj'></bdo><ul id='vNBnj'></ul>

                • <legend id='vNBnj'><style id='vNBnj'><dir id='vNBnj'><q id='vNBnj'></q></dir></style></legend>

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

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

                    <tfoot id='vNBnj'></tfoot>