1

Using php to i created csv file. we using umlaut symbols in my csv file, is not show correct form in .csv files.

I adding spanish text is " DIRECCIÓN ", but i got result like this " DIRECCIÓN "

$filename = "ConnectionsData.csv";

header('Content-Encoding: UTF-8');
header('Content-type: text/csv; charset=UTF-8');
header("Content-Disposition: attachment; filename=\"$filename\"");
//header("Content-Type: text/csv");

$display = fopen("php://output", 'w');

$flag = false;
while($row = mysql_fetch_assoc($query_profiler)) {
    if(!$flag) {
      // display field/column names as first row
 if($x==0){
       fputcsv($display, str_replace($tab_name, $rep_tab,array_keys($row)), ",", '"');
        $flag = true;
 }
    }
    fputcsv($display, array_values(str_replace("'","'",str_replace("~/"," ",$row))), ",", '"');
  }

fclose($display);
}
bala15
  • 31
  • 2
  • 5
  • Have a look at this: http://stackoverflow.com/questions/21988581/write-utf-8-characters-to-file-with-fputcsv-in-php – twain Nov 26 '14 at 09:59
  • 1
    Your file is fine. But you can't just double-click a UTF-8 file and get it correctly opened in Microsoft Office Excel: Microsoft apps in a Spanish computer will assume Windows-1252. – Álvaro González Nov 26 '14 at 10:00
  • Thanks Mr.twain and Mr. Alvaro G. Vicario, I am tired its working properly. Thanks for the help! – bala15 Nov 26 '14 at 13:11

0 Answers0