title: Mongo utf-8 exception handling
body: <p>I have a problem with inserting data to mongodb.</p>
  
  <pre><code>$name = $_REQUEST['name']; // "Iñtërnâtiônàlizætiøn";
  $db-&gt;table-&gt;insert(
     array('name' =&gt; $name)
  );
  </code></pre>
  
  <p>This gives mongo exception "Fatal error: Uncaught exception 'MongoException' with message 'non-utf8 string:...."</p>
  
  <p><code>$name = mb_convert_encoding($_REQUEST['name'], 'ISO-8859-1', 'UTF-8');</code></p>
  
  <p>Helps to fix the issue. But is there a way to force php to set all incoming data to utf-8, so I won't need to use mb_convert_encoding for each data?</p>
  
  <p>I tried </p>
  
  <pre><code>mb_internal_encoding('UTF-8');
  iconv_set_encoding('input_encoding', 'UTF-8');
  iconv_set_encoding('internal_encoding', 'UTF-8');
  </code></pre>
  
  <p>None of those helped.</p>
  
  <p>Even </p>
  
  <pre><code>mb_detect_encoding($_REQUEST['title']);
  </code></pre>
  
  <p>gives: 'UTF-8' but mongo exception still occures.</p>