【问题标题】:UTF 8 and Windows 1254 charset mismatchUTF 8 和 Windows 1254 字符集不匹配
【发布时间】:2012-06-20 14:43:21
【问题描述】:

我正在使用 Drupal 7。我创建了一个块并嵌入了这段代码:

 $contents = file_get_contents('http://www.tcmb.gov.tr/kurlar/today.html'); 

我的网站字符集:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

而外部链接字符集是:

<META HTTP-EQUIV=Content-Type  CONTENT=text/html;charset=windows-1254>

所以,当我获得一些关于外部链接的信息时,我遇到了字符问题(没有看到 İ、ç、ş 等)

我该如何解决这个问题?

【问题讨论】:

    标签: php utf-8 character-encoding utf


    【解决方案1】:

    在你的块中,我会创建这两行:

    $contents = file_get_contents('http://www.tcmb.gov.tr/kurlar/today.html');
    $contents = iconv("windows-1254" , "UTF-8" , $contents);
    

    所以此页面的内容将是 UTF-8,与您的页面相同。

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 1970-01-01
      • 2012-08-22
      • 2011-02-26
      • 1970-01-01
      • 1970-01-01
      • 2012-01-14
      • 2015-06-02
      • 2013-05-26
      相关资源
      最近更新 更多