PHP: Convert curl_exec output to UTF8
- by Paul Tarjan
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()?