title: PHP: checking if string is utf-8 or utf-16le
body: <p>I'm writing function that returns document in utf-8 by default, by if you provide special parameter it will return content in utf-16le. I started to write unit test for this function and what I don't understand is how to check if encoding is "utf-8" or "utf-16le". I've tried <code>mb_detect_encoding</code> but it returns <code>false</code> even in this code snippet:</p>
  
  <pre><code>  $utf16Doc = mb_convert_encoding($doc, "utf-16le", "utf8");
    $test = mb_detect_encoding($utf16Doc, "utf-16le");
    var_dump($test);
  </code></pre>
  
  <p>Appreciate any ideas how to check in test that encoding is utf-16le and not utf-8.</p>