• <tfoot id='9CSBO'></tfoot>

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

        <small id='9CSBO'></small><noframes id='9CSBO'>

        将 utf8 字符转换为 iso-88591 并在 PHP 中返回

        时间:2023-10-04
          <tfoot id='ORQrE'></tfoot>
            <bdo id='ORQrE'></bdo><ul id='ORQrE'></ul>

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

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

                  <tbody id='ORQrE'></tbody>
                  本文介绍了将 utf8 字符转换为 iso-88591 并在 PHP 中返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我的一些脚本使用了不同的编码,当我尝试将它们组合起来时,这已经成为一个问题.

                  Some of my script are using different encoding, and when I try to combine them, this has becom an issue.

                  但我不能改变他们使用的编码,相反我想改变脚本 A 结果的编码,并将其用作脚本 B 中的参数.

                  But I can't change the encoding they use, instead I want to change the encodig of the result from script A, and use it as parameter in script B.

                  那么:有没有什么简单的方法可以在 PHP 中将字符串从 UTF-8 更改为 ISO-88591?我看过 utf_encode 和 _decode,但它们没有做我想要的.为什么不存在任何utf2iso()"函数或类似函数?

                  So: is there any simple way to change a string from UTF-8 to ISO-88591 in PHP? I have looked at utf_encode and _decode, but they doesn't do what i want. Why doesn't there exsist any "utf2iso()"-function, or similar?

                  我不认为我有不能以 ISO 格式写入的字符,所以这应该不是一个大问题.

                  I don't think I have characters that can't be written in ISO-format, so that shouldn't be an huge issue.

                  推荐答案

                  看看 iconv()mb_convert_encoding().顺便说一句:为什么不 utf8_encode()utf8_decode() 对你有用吗?

                  Have a look at iconv() or mb_convert_encoding(). Just by the way: why don't utf8_encode() and utf8_decode() work for you?

                  utf8_decode — 将字符串转换为ISO-8859-1 字符编码为UTF-8 到单字节 ISO-8859-1

                  utf8_decode — Converts a string with ISO-8859-1 characters encoded with UTF-8 to single-byte ISO-8859-1

                  utf8_encode — 编码 ISO-8859-1字符串转 UTF-8

                  utf8_encode — Encodes an ISO-8859-1 string to UTF-8

                  本质上

                  $utf8 = 'ÄÖÜ'; // file must be UTF-8 encoded
                  $iso88591_1 = utf8_decode($utf8);
                  $iso88591_2 = iconv('UTF-8', 'ISO-8859-1', $utf8);
                  $iso88591_2 = mb_convert_encoding($utf8, 'ISO-8859-1', 'UTF-8');
                  
                  $iso88591 = 'ÄÖÜ'; // file must be ISO-8859-1 encoded
                  $utf8_1 = utf8_encode($iso88591);
                  $utf8_2 = iconv('ISO-8859-1', 'UTF-8', $iso88591);
                  $utf8_2 = mb_convert_encoding($iso88591, 'UTF-8', 'ISO-8859-1');
                  

                  所有人都应该这样做 - utf8_en/decode() 不需要特殊扩展,mb_convert_encoding() 需要 ext/mbstring 和 iconv() 需要 ext/iconv.

                  all should do the same - with utf8_en/decode() requiring no special extension, mb_convert_encoding() requiring ext/mbstring and iconv() requiring ext/iconv.

                  这篇关于将 utf8 字符转换为 iso-88591 并在 PHP 中返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                      <bdo id='IFvJL'></bdo><ul id='IFvJL'></ul>

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

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

                        <tfoot id='IFvJL'></tfoot>