PHP export CSV when data having UTF8 charcters
csv, excel, php, unicode
Solution
This post solved my problem: https://stackoverflow.com/a/4762708/2349494
And this is what did the conversion:
print chr(255) . chr(254) . mb_convert_encoding($csv_output, 'UTF-16LE', 'UTF-8');
Earlier I was getting garbage characters now correct data is exported.
Problem
In MySQL I have set my data field type to `utf8_bin` and i am storing data in Unicode. Texts are being properly displayed in web pages. I want to generate excel file exporting data from my table to it. The output in `.xls` and `.cvs` is - '????'. I checkout out other answers here, its been referred to use headers: `header("content-type:application/csv;charset=UTF-8");` similar question. But its not working. After using header, in csv Output is - सूरà¥à¤¯à¤¾. Please help. Thanks.