-1

When i open a php generated csv file by using notepad or any other text editor i am able to see utf-8 characters as it is no issue here. But when i double click the file to open in excel utf-8 characters are displaying as special characters like this.

Lahnstraße
Below is the code to generate csv file .
$fh1 = fopen($current_csv_name, 'w+');
fprintf($fh1, "\xEF\xBB\xBF");
foreach($csv_data as $response)
{
   fputs($fh1, implode($response, ';')."\n");
}
fclose($fh1);

Any help would be greatly appreciated.

user3408779
  • 981
  • 2
  • 19
  • 43

1 Answers1

0

try to generate in this way and then open it in Excel,

header('Content-Type: application/excel');
header('Content-Disposition: attachment; filename="SomeName.csv"');
$fp = fopen('php://output', 'w');
foreach ( $data as $line ) {
     $val = explode(",", $line);
     fputcsv($fp, $val);
}
fclose($fp);
Soni Vimalkumar
  • 1,449
  • 15
  • 26