title: PHP Curl UTF-8 Charset
body: <p>I have an php script which calls another web page and writes all the html of the page and everything goes ok however there is a charset problem. My php file encoding is utf-8 and all other php files work ok (that means there is no problem with server). What is the missing thing in that code and all spanish letters look weird. PS. When I wrote these weird characters original versions into php, they all look accurate.</p>
  
  <pre><code>header("Content-Type: text/html; charset=utf-8");
  function file_get_contents_curl($url)
  {
      $ch=curl_init();
      curl_setopt($ch,CURLOPT_HEADER,0);
      curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch,CURLOPT_URL,$url);
      curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
      $data=curl_exec($ch);
      curl_close($ch);
      return $data;
  }
  $html=file_get_contents_curl($_GET["u"]);
  $doc=new DOMDocument();
  @$doc-&gt;loadHTML($html);
  </code></pre>