title: Character encoding issue with PDO_ODBC
body: <p>When accessing a Microsoft SQL Database from PHP using PDO_ODBC with the following code, I have an encoding issue. When outputed the text from the DB is garbled.</p>
  
  <pre><code>$dsn = "odbc:DRIVER={SQL Server};SERVER=$hostname;DATABASE=$database;charset=UTF-8";
  $pdo = new PDO($dsn,$username,$password);
  $sql = "SELECT text FROM atable";
  $result = $PDO-&gt;query($sql);
  while($data = $result-&gt;fetchObject()){
    $values[] = $data-&gt;text; 
  }
  dpm($values);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rJ0D2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rJ0D2.jpg" alt="garbled output"></a><br>
  <sub>(source: <a href="http://image.bayimg.com/naomcaacd.jpg" rel="nofollow noreferrer">bayimg.com</a>)</sub>  </p>
  
  <p>This is done from a Drupal module. Everything in Drupal is made to work with UTF-8. The cleanest solution would be to able to retrieve the data from the database in UTF-8 or to convert it UTF-8 before outputting. </p>
  
  <p>I tried these without any success</p>
  
  <ul>
  <li><code>$dsn = "odbc:DRIVER={SQL Server};SERVER=$hostname;DATABASE=$database;client_charset=utf-8"</code></li>
  <li><code>$dsn = "odbc:DRIVER={SQL Server};SERVER=$hostname;DATABASE=$database;charset=utf-8"</code></li>
  <li><code>$pdo-&gt;exec('SET NAMES utf8')</code> after <code>new PDO(...)</code></li>
  <li><code>$pdo-&gt;exec('SET CHARACTER SET utf8');</code> after <code>new PDO(...)</code></li>
  </ul>
  
  <p>PS: The code is currently developped on Windows but it has to work on GNU/Linux too.</p>