Forums / Developer / csv problem encoding utf-8
Amine BETARI
Monday 24 January 2011 1:44:18 am
Hello, I generate csv files via a module, my problem is the encoding: for example civility displayed Civility © when I open the csv file directly with double click. by cons when I open the csv file with notepad ++ or via Excel (Data -> External Data -> Import data -> select the encoding etc..) it works very well you have an idea?
Frédéric RINALDI
Monday 24 January 2011 2:12:52 am
Dear Amine,
I suppose you use header functions to export to CSV?
header("Content-Disposition: attachment; filename='yourCsvFile.csv" ) ; header("Cache-Control: cache, must-revalidate" ) ;header("Pragma: public" ) ;
Do you use a encoding feature?header('Content-Type: text/xml, charset=UTF-8; encoding=UTF-8');
Yours,
Monday 24 January 2011 4:05:22 am
I use: header('Content-Type: application/csv; utf-8'); header("Content-Type: application/force-download"); header('Content-Disposition: attachment; filename="'.$fileName.'.csv"'); but I tried to use what you offered me but I had the same problem Thank you very much
Monday 24 January 2011 8:05:25 am
Do you try utf8_encode function? and maybe mb_detect_encoding to get the wrong encoding of your content.
Monday 24 January 2011 9:08:53 am
which is weird, I used the function utf_decode () for words containing accents and it works well !!!!!!!!!!!!!!!!!