• <small id='WeN0O'></small><noframes id='WeN0O'>

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

      <tfoot id='WeN0O'></tfoot>
      • <bdo id='WeN0O'></bdo><ul id='WeN0O'></ul>
    1. <legend id='WeN0O'><style id='WeN0O'><dir id='WeN0O'><q id='WeN0O'></q></dir></style></legend>

        在 php 中将 UTF-16LE 转换为 UTF-8

        时间:2023-10-03
        1. <i id='UIiPK'><tr id='UIiPK'><dt id='UIiPK'><q id='UIiPK'><span id='UIiPK'><b id='UIiPK'><form id='UIiPK'><ins id='UIiPK'></ins><ul id='UIiPK'></ul><sub id='UIiPK'></sub></form><legend id='UIiPK'></legend><bdo id='UIiPK'><pre id='UIiPK'><center id='UIiPK'></center></pre></bdo></b><th id='UIiPK'></th></span></q></dt></tr></i><div id='UIiPK'><tfoot id='UIiPK'></tfoot><dl id='UIiPK'><fieldset id='UIiPK'></fieldset></dl></div>
            <bdo id='UIiPK'></bdo><ul id='UIiPK'></ul>

              <tbody id='UIiPK'></tbody>
            <tfoot id='UIiPK'></tfoot>
            • <legend id='UIiPK'><style id='UIiPK'><dir id='UIiPK'><q id='UIiPK'></q></dir></style></legend>

              • <small id='UIiPK'></small><noframes id='UIiPK'>

                  本文介绍了在 php 中将 UTF-16LE 转换为 UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我使用 iconv php 函数,但有些字符不能正确转换:

                  I use iconv php function but some characters doesn't convert correctly:

                  ...
                  $s = iconv('UTF-16', 'UTF-8', $s);
                  ...
                  $s = iconv('UTF-16//IGNORE', 'UTF-8', $s);
                  ...
                  $s = iconv('UTF-16LE', 'UTF-8', $s);
                  ...
                  $s = iconv('UTF-16LE//IGNORE', 'UTF-8', $s);
                  ...
                  

                  我也尝试了 mb_convert_encoding 函数,但无法解决我的问题.

                  I also try mb_convert_encoding function but can't solve my problem.

                  示例文本文件:9px.ir/utf8-16LE.rar

                  A sample text file: 9px.ir/utf8-16LE.rar

                  推荐答案

                  iconv 支持UTF-16LE编码.

                  您可以使用它来将编码从 UTF-16LE 转置为 UTF-8:

                  You can use it to transpose the encoding from UTF-16LE to UTF-8:

                  $result = iconv($in_charset = 'UTF-16LE' , $out_charset = 'UTF-8' , $str);
                  if (false === $result)
                  {
                      throw new Exception('Input string could not be converted.');
                  }
                  

                  参见iconv文档.

                  我只是想知道 UTF 中的所有代码点是否可用-16LEUTF-8 中可用.但我认为这应该适合您的情况.

                  I'm just wondering if all code-points available in UTF-16LE are available in UTF-8. But I assume that this should fit in your case.

                  我无法在自己的盒子上重现该问题,但在 另一个框我遇到了这个通知:

                  I was not able to reproduce the problem on a box of my own, but on another box I ran into this notice:

                  注意:iconv() [function.iconv]: 字符集错误,从 UTF-16LE' 到 UTF-8' 的转换是不允许的 ...

                  Notice: iconv() [function.iconv]: Wrong charset, conversion from UTF-16LE' toUTF-8' is not allowed in ...

                  看起来并不是所有的 iconv 版本都能真正将 UTF-16LE 转换为 UTF-8.

                  Looks like that not all iconv versions can actually convert UTF-16LE to UTF-8.

                  使用 mb_convert_encodingDocs 相反,至少在这种情况下是这样 (演示):

                  It might be a workaround to use mb_convert_encodingDocs instead, at least it was in this case (Demo):

                  $result = mb_convert_encoding($str , 'UTF-8' , 'UTF-16LE');
                  

                  这篇关于在 php 中将 UTF-16LE 转换为 UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:未在 html 文档中声明的字符编码 下一篇:用 JavaScript 编码 Base64,用 GET 发送,用 PHP 解码

                  相关文章

                  最新文章

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

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