UTF 8 和 Windows 1254 字符集不匹配


UTF 8 and Windows 1254 charset mismatch

我正在使用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>

所以,当在外部链接上获取一些信息时,我有字符问题(看不到 İ、ç、ş 等)。

我该如何解决这个问题?

在您的块中,我将创建以下两行:

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

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