PHP: Convert curl_exec output to UTF8

Posted by Paul Tarjan on Stack Overflow See other posts from Stack Overflow or by Paul Tarjan
Published on 2010-03-24T19:41:19Z Indexed on 2010/03/28 1:43 UTC
Read the original article Hit count: 493

Filed under:
|
|
|

I would like to only work with UTF8. The problem is I don't know the charset of every webpage. How can I detect it and convert to UTF8?

<?php
$url = "http://vkontakte.ru";
$ch = curl_init($url);
$options = array(
    CURLOPT_RETURNTRANSFER => true,
);
curl_setopt_array($ch, $options);
$data = curl_exec($ch);

// $data = magic($data);

print $data;

See this at: http://paulisageek.com/tmp/curl-utf8

What is magic()?

© Stack Overflow or respective owner

Related posts about utf-8

Related posts about unicode