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

      • <bdo id='E4UcS'></bdo><ul id='E4UcS'></ul>
      <i id='E4UcS'><tr id='E4UcS'><dt id='E4UcS'><q id='E4UcS'><span id='E4UcS'><b id='E4UcS'><form id='E4UcS'><ins id='E4UcS'></ins><ul id='E4UcS'></ul><sub id='E4UcS'></sub></form><legend id='E4UcS'></legend><bdo id='E4UcS'><pre id='E4UcS'><center id='E4UcS'></center></pre></bdo></b><th id='E4UcS'></th></span></q></dt></tr></i><div id='E4UcS'><tfoot id='E4UcS'></tfoot><dl id='E4UcS'><fieldset id='E4UcS'></fieldset></dl></div>
      <legend id='E4UcS'><style id='E4UcS'><dir id='E4UcS'><q id='E4UcS'></q></dir></style></legend>
    1. <tfoot id='E4UcS'></tfoot>
    2. 如何检测是否必须对字符串应用 UTF-8 解码或编码

      时间:2023-10-05

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

          <small id='50x1D'></small><noframes id='50x1D'>

          <tfoot id='50x1D'></tfoot>
              <bdo id='50x1D'></bdo><ul id='50x1D'></ul>
            • <legend id='50x1D'><style id='50x1D'><dir id='50x1D'><q id='50x1D'></q></dir></style></legend>
              • 本文介绍了如何检测是否必须对字符串应用 UTF-8 解码或编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我有从第三方网站获取的提要,有时我必须应用 utf8_decode 和其他时候 utf8_encode 以获得所需的可见输出.

                I have a feed taken from third-party sites, and sometimes I have to apply utf8_decode and other times utf8_encode to get the desired visible output.

                如果错误地应用相同的东西两次/或使用了错误的方法,我会得到更丑陋的东西,这就是我想要改变的.

                If by mistake the same stuff is applied twice/or the wrong method is used I get something more ugly, this is what I want to change.

                如何检测何时必须对字符串应用什么?

                How can I detect when what have to apply on the string?

                其实内容返回的是UTF-8,但里面有部分不是.

                Actually the content returns UTF-8, but inside there are parts that are not.

                推荐答案

                我不能说我可以依赖 mb_detect_encoding().不久前我遇到了一些奇怪的误报.

                I can't say I can rely on mb_detect_encoding(). I had some freaky false positives a while back.

                我发现在每种情况下都能很好地工作的最普遍的方法是:

                The most universal way I found to work well in every case was:

                if (preg_match('!!u', $string))
                {
                   // This is UTF-8
                }
                else
                {
                   // Definitely not UTF-8
                }
                

                这篇关于如何检测是否必须对字符串应用 UTF-8 解码或编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:在php中使用fputcsv将utf-8字符写入文件 下一篇:土耳其语字符显示不正确

                相关文章

                最新文章

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

                1. <tfoot id='CUirH'></tfoot>

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

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