title: Em Dash and En Dash from MySQL Db with PHP
body: <p>I'm trying out output a MySQL database field with PHP which contains em dash and en dash, but although the ROWs output, the values with these dashes do not.</p>
  
  <p>As far as I am aware, these are characters which should be used in proper english, therefore I don't think I should be stripping them out or replacing them with an alternative (like a hyphen).</p>
  
  <p>By adding this code before the INSERT, I am able to get the em dash and en dash into the database properly (whereas without this line I saw unwanted characters instead):</p>
  
  <pre><code>mysql_query('SET NAMES utf8');
  </code></pre>
  
  <p>But, the value won't output. The database table and it's fields are using the utf8_general_ci collation and I've got these lines in my PHP page:</p>
  
  <pre><code>header('Content-type: text/html; charset=utf-8');
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
  </code></pre>
  
  <p>I'm outputting the value like so:</p>
  
  <pre><code>echo nl2br(htmlentities(preg_replace("/[\r\n]+/", "\n\n", $row['someText'])));
  </code></pre>
  
  <p>If I output the value without formatting, I see this question mark character:</p>
  
  <p>�</p>
  
  <p>Does anyone know how to get around this? Am I forced to replace them with hyphens even though that's grammatically incorrect, or is there a way to output them as they appear in the database?</p>