title: Howto import xls/csv file with unicode charset into php/mysql?
body: <p>I want to give the user the ability to import a csv file into my php/mysql system, but ran into some problems with encoding when the language is russian which excel only can store in UTF-16 tab-coded tab files.</p>
  
  <p>Right now my database is in latin1, but I will change that to utf-8 as described in question "a-script-to-change-all-tables-and-fields-to-the-utf-8-bin-collation-in-mysql"</p>
  
  <p>But how should I import the file? and store the strings?</p>
  
  <p>Should I for example translate it to html_entitites?</p>
  
  <p>I am using the <code>fgetcsv</code> command to get the data out of the csv file.
  My code looks something like this right now.</p>
  
  <pre><code>
  file_put_contents($tmpfile, str_replace("\t", ";", file_get_contents($tmpfile)));
  $filehandle = fopen($tmpfile,'r');
  while (($data = fgetcsv($filehandle, 1000, ";")) !== FALSE) {
    $values[] = array(
      'id' => $data[0], 
      'type' => $data[1], 
      'text' => $data[4], 
      'desc' => $data[5], 
      'pdf' => $data[7]);
  }
  </code>
  </pre>
  
  <p>As note, if I store the xls file as csv in excel, i special chars are replaced by '_', so the only way I can get the russian chars out of the file, is to store the file in excel as tabbed seperated file in UTF16 format.</p>