title: UTF-8 Corrupted from MySQL to SQLite
body: <p>I'm porting a PHP Web application I wrote from MySQL 5 to SQLite 3. The text encoding for both is UTF-8 (for all fields, tables, and databases). I'm having trouble transferring a geo database with special characters.</p>
  
  <p><code>mb_detect_encoding()</code> detects both as returning UTF-8 data.</p>
  
  <p>For example,</p>
  
  <p><strong>Raw output:</strong></p>
  
  <p>MySQL (correct): Dārāb, Iran<br>
  SQLite (incorrect): DÄrÄb, Iran</p>
  
  <p><strong>JSON-encoded:</strong></p>
  
  <p>MySQL (correct): D\u0101r\u0101b, Iran<br>
  SQLite (incorrect): D\u00c4\u0081r\u00c4\u0081b, Iran</p>
  
  <p><strong>What fixes the problem:</strong></p>
  
  <pre><code>$sqlite_output = utf8_encode($sqlite_output);
  $sqlite_output = utf8_decode($sqlite_output);
  </code></pre>
  
  <p>I imagine there's a way of repairing the SQLite database. Thank you in advance.</p>