Accented characters like enie (ñ) are difficult to handle when generating CSV files. The tendency is one might end up having different and unexpected characters.
In my case, the CSV file I generated got a \1\1
instead of ñ
. Thus instead of having Niño
it got Ni\1\1o
.
Is this even possible to fix? How to generate a CSV file with accented characters using PHP?
You can encode the data check
http://php.net/manual/en/function.mb-convert-encoding.php
You can try this
header('Content-Encoding: UTF-8');
header('Content-type: text/csv; charset=UTF-8');
header('Content-Disposition: attachment; filename=Customers_Export.csv');
echo "\xEF\xBB\xBF";