1

I'm generating csv file but it save as "UTF-8 without BOM"

how can I save as "UTF-8 with BOM" ?

I'm using following header in codeigniter

 header('Content-Type: text/csv;charset=utf-8');
Ali
  • 3,545
  • 11
  • 44
  • 63
  • possible duplicate of [How to write file in UTF-8 format?](http://stackoverflow.com/questions/4839402/how-to-write-file-in-utf-8-format) – Gergo Erdosi Jul 09 '14 at 10:52

1 Answers1

5

This is already a duplicate of How can I output a UTF-8 CSV in PHP that Excel will read properly?

However you need to include a Byte Order Mark. This can be done in this way: https://stackoverflow.com/a/7601168/678611

<?php

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=<a filename>.csv');
header('Content-Transfer-Encoding: binary');

echo "\xEF\xBB\xBF"; // Byte Order Mark
echo $the_csv_file_content;
exit();

?>
Community
  • 1
  • 1
Diblo Dk
  • 585
  • 10
  • 26