title: How to correctly store/retrieve UTF-8 Data into MS-SQL tables
body: <p>i'm having big trouble storing extended characters from UTF-8 in MS-SQL Server Tables.</p>
  
  <p>Every extended character stored in in ASCII-extended range (8-bit). i didn't find any way to store and not distort the information stored or losing extended character info data.</p>
  
  <p>my current setup for the server is:</p>
  
  <ul>
  <li>IIS 7.5 </li>
  <li>PHP 5.6.11 (x86_64 VC11 Fast-CGI)</li>
  <li>SQL Server Native Client for SQL Server 2008 R2 8 (Used via ODBC)</li>
  </ul>
  
  <p>Why i'm not using SQL-Server driver Extension for PHP, simple, Microsoft don't have any available build version of that driver for 64-bit.</p>
  
  <p>What i have tried so far:</p>
  
  <ul>
  <li>my Fields are Nvarchar, Nchar datatype.</li>
  <li>Used <code>utf8_decode()</code> to prepare the date for INSERT/UPDATE statements</li>
  <li>Used <code>utf8_encode()</code> when i retrieve the Data with the SELECTs</li>
  <li>Used <code>mb_convert_encoding($string,[new_encoding],'UTF-8');</code> Where new encoding was Windows-1252, UCS-2, ASCII. (in subtitution of utf8_decode)</li>
  <li>Used <code>iconv();</code> With encoding CP437.(in subtitution of utf8_decode)</li>
  </ul>
  
  <p>no success in any case.</p>
  
  <p>what i'm experimenting when data is stored, and you make a SELECT directly into the database the extended characters in strings are shown as garbage.</p>
  
  <p>lets say:</p>
  
  <p>i write <code>"ánimo"</code> and that word its stored  as <code>"Ã¡nimo"</code> when i retrieve from table to screen displays as <code>"Ã¡nimo"</code></p>
  
  <pre><code>input ----&gt; decode_utf8() ---&gt; MS-SQL ----&gt; encode_utf8()---&gt; screen
  </code></pre>
  
  <p>any Ideas ???</p>