title: Reading Unicode characters from MySQL with PHP
body: <p>I've inherited a MySQL database which contains a field named Description of type text and collation of <code>latin1_swedish_ci</code>.</p>
  
  <p>The problem with this field is it contains utf-8 data with some Unicode characters, e.g. character 733, etc. Sometimes this character also exists in the field represented as HTML encoded "&amp;#733" as well.</p>
  
  <p>I'm trying to read the table and export the data to a CSV file and I need to represent this character as a double quote.</p>
  
  <p>Reading the HTML encoded character is easy enough. However, it appears that the actual Unicode character is converted to utf-8 before I can do anything with it resulting in a "?".</p>
  
  <p>How do I read in the Unicode character 733 (U+02DD), recognize it and convert it?</p>
  
  <p>Here's a simplified (not tested) version of the code.</p>
  
  <pre><code>&lt;?
  $testconn=odbc_connect ("TESTLIB", "......", "......");
  
  $query="SELECT Description FROM TestTable";
  
  $rsWeb=mysql_query($query));
  
  $WebRow=mysql_fetch_row($rsWeb));
  $Desc = $WebRow[0];
  $Desc = str_replace('"','""',$Desc);
  
  fwrite($output,"\"".$Desc."\",\r\n");
  %&gt;
  </code></pre>