Skip to content
Advertisement

UTF 8 and Windows 1254 charset mismatch

I’m using Drupal 7. And i created a block and embed this code:

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

My site charset:

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

And external link charset is:

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

So, when get some info on external link, i have character problem (don’t seen İ, ç, ş etc..)

How can i solve this?

Advertisement

Answer

In your block, I would create these two lines:

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

so this page’s contents will be UTF-8, the same as your pages.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement