title: Why do I get invalid characters when converting MS SQL Data to MYSQL?
body: <p>I'm writing a PHP script to import data into a MYSQL database from a Microsoft SQL Server 2008 database.</p>
  
  <p>The MSSQL Server is set with a collation of "SQL_Latin1_General_CP1_CI_AS" and the data in question is being stored in a column of the type "nchar".</p>
  
  <p>My PHP web pages use</p>
  
  <pre><code>&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;
  </code></pre>
  
  <p>to indicate that they should be displayed with UTF-8 Character encoding.</p>
  
  <p>I'm pulling the data from the MSSQL database using the sqlsrv PHP extension.</p>
  
  <pre><code>$sql = 'SELECT * FROM [tArticle] WHERE [ID] = 6429';
  $stmt = &amp;sqlsrv_query($dbHandler, $sql);
  
  while ($row = sqlsrv_fetch_object($stmt)) {
    // examples of what I've tried simply to display the data
    echo $row-&gt;Text1;
    echo utf8_encode($row-&gt;Text1);
    echo iconv("ISO-8859-1", "UTF-8", $row-&gt;Text1);
    echo iconv("ISO-8859-1", "UTF-8//TRANSLIT", $row-&gt;Text1);
  }
  </code></pre>
  
  <p>Forget about inserting the data into the MYSQL database for now.  I can't get the string to display properly in my PHP page.  From the examples in my listing:</p>
  
  <pre><code>echo $row-&gt;Text1
  </code></pre>
  
  <p>is rendered by my browser as an obviously invalid character:  "Lucy�s"</p>
  
  <p>all of the examples following that one are rendered as blanks:  "Lucys"</p>
  
  <p>It looks like a character set mismatch problem to me but how can I get this data to display properly from the MS SQL database (without changing my web-page encoding)?  If I can figure that out I can probably work out the storing it in the MYSQL database part.</p>