title: Special characters in UTF-8 stored as diamond with question mark in MYSQL using magento
body: <p>I am reading a csv encoded in UTF-8 with some special characters such as <code>ò</code> . I use htmlentities to store the UTF-8 characters to their HTML equivalent. But such special characters get stored as diamond with question mark in MYSQL db.</p>
  
  <p>My code is :- </p>
  
  <pre><code>$fileName = $_FILES['csv_file']['tmp_name'];
  ini_set('auto_detect_line_endings', 1);
  $fp = fopen($fileName, 'r');
  
  $resource = Mage::getSingleton('core/resource');
  $writeAdapter = $resource-&gt;getConnection('core_write');
  $optionsNumber = 4;
  
  $line = true;
  while ($line !== false){
      $names      = array();
      $namesIndex = 0;
      while (($line = fgetcsv($fp, self::MAX_LINE, ',', '"')) !== false) {
  
          $empty_row = false;
          for ($i = 0; $i &lt; $optionsNumber+1; $i++) {
              $line[$i] = trim($line[$i], "\r\n\t' ".'"');
              $line[$i] = htmlentities($line[$i], ENT_SUBSTITUTE, "UTF-8");
  
              $sql2 = "insert ignore into `custom_table` ". "(parent_id, options_id, value, p_id) values ". "(:parent_id, :options_id, :value,:p_id)";
  
              $binds = array(
                  'parent_id'      =&gt; 0,  
                  'options_id'     =&gt; 1,
                  'value'          =&gt; $line[$i],
                  'p_id'           =&gt; 1,
              );
              $writeAdapter-&gt;query($sql2,$binds);
          }       
      }   
  }
  </code></pre>
  
  <p>Now the problem is the value <code>Motò 6.5</code> is stored as <code>Mot� 6.5</code></p>
  
  <p>Someone please point out what is the mistake. Thanks in advance.</p>