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

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

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

      1. <tfoot id='O1U4e'></tfoot>
      2. file_get_contents() 分解 UTF-8 字符

        时间:2023-10-03

          <tbody id='kyfx8'></tbody>

        <tfoot id='kyfx8'></tfoot>
          <legend id='kyfx8'><style id='kyfx8'><dir id='kyfx8'><q id='kyfx8'></q></dir></style></legend>

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

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

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

                  本文介绍了file_get_contents() 分解 UTF-8 字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在从外部服务器加载 HTML.HTML 标记具有 UTF-8 编码并包含诸如 ľ,š,č,ť,ž 等字符.当我使用 file_get_contents() 加载 HTML 时,如下所示:

                  I am loading a HTML from an external server. The HTML markup has UTF-8 encoding and contains characters such as ľ,š,č,ť,ž etc. When I load the HTML with file_get_contents() like this:

                  $html = file_get_contents('http://example.com/foreign.html');
                  

                  它弄乱了 UTF-8 字符并加载了 Å、¾、¤ 和类似的废话,而不是正确的 UTF-8 字符.

                  It messes up the UTF-8 characters and loads Å, ¾, ¤ and similar nonsense instead of proper UTF-8 characters.

                  我该如何解决这个问题?

                  How can I solve this?

                  更新:

                  我尝试将 HTML 保存到文件并使用 UTF-8 编码输出.两者都不起作用,所以这意味着 file_get_contents() 已经返回损坏的 HTML.

                  I tried both saving the HTML to a file and outputting it with UTF-8 encoding. Both doesn't work so it means file_get_contents() is already returning broken HTML.

                  更新2:

                  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sk" lang="sk">
                  <head>
                  
                  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
                  <meta http-equiv="Content-Style-Type" content="text/css" />
                  <meta http-equiv="Content-Language" content="sk" />
                  <title>Test</title>
                  
                  </head>
                  <body>
                  
                  
                  <?php
                  
                  $html = file_get_contents('http://example.com');
                  echo htmlentities($html);
                  
                  ?>
                  
                  </body>
                  </html>
                  

                  推荐答案

                  好的.我发现 file_get_contents() 没有导致这个问题.我在另一个问题中谈到了不同的原因.傻我.

                  Alright. I have found out the file_get_contents() is not causing this problem. There's a different reason which I talk about in another question. Silly me.

                  看到这个问题:为什么DOM会改变编码?

                  这篇关于file_get_contents() 分解 UTF-8 字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:PHP:用 UTF-8 字符串中最接近的 7 位 ASCII 等价物替 下一篇:PHP 文件中的 UTF-8 BOM 签名

                  相关文章

                  最新文章

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

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

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

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