title: How to convert any character encoding to UTF8 on PHP
body: <p>I'm working on a web crawler that grabs data from sites all over the world, and is dealing with distinct languages and encodings.</p>
  
  <p>Currently I'm using the following function, and it works in 99% of the cases. But there is this 1% that is giving me headaches.</p>
  
  <pre><code>function convertEncoding($str) {
      return iconv(mb_detect_encoding($str), "UTF-8", $str);
  }
  </code></pre>