title: How to retrieve utf-8 data with php and show the correct encoding in an excelsheet db dump?
body: <p>Hi I am saving mostly english and german characters into a mysql database which currently is set to utf-8 charset.</p>
  
  <p>I am assuming that I should use latin1 charset for this type of data, is that correct?</p>
  
  <p>If so how can I change the charset to correct the german chars which are now saved in utf-8?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Maybe then it is a retrival problem ... When I export data from the db via php of course I get utf-8 back, can I do the retrival to give me latin1?</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>Ok I am building a website, the html encoding is uft-8 the db is uft-8, and now I want to run some exports and extract data, which should be returned in an excel sheet, and the data is utf-8, but here I need the chars to be latin1 ... or the encoding of the excel sheet extracted from the db need to be such that TÃ¶st will show Täst. Right now I get the data like this -> TÃ¶st</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>I am using following php script to do the dump:</p>
  
  <p><a href="http://www.fundisom.com/phparadise/php/databases/mySQL_to_excel" rel="nofollow">http://www.fundisom.com/phparadise/php/databases/mySQL_to_excel</a></p>
  
  <p>on line 48 I have changed the code to  </p>
  
  <pre><code>header("Content-Type: application/$file_type; charset=utf-8");
  </code></pre>
  
  <p>no change in behaviour.</p>
  
  <p>How would I solve the issue?</p>
  
  <p><strong>Almost Solution</strong></p>
  
  <pre><code>&lt;?php
  $text = "Ã¶ is a valid UTF-8 character";
  echo 'Original : ', $text, PHP_EOL;
  echo 'TRANSLIT : ', iconv("UTF-8", "ISO-8859-1//TRANSLIT", $text), PHP_EOL;
  echo 'IGNORE   : ', iconv("UTF-8", "ISO-8859-1//IGNORE", $text), PHP_EOL;
  echo 'Plain    : ', iconv("UTF-8", "ISO-8859-1", $text), PHP_EOL;
  ?&gt;
  </code></pre>
  
  <p>this is what I need I think ... but I need to check it in context of the php script... tomorrow :-)</p>