Answer the question
In order to leave comments, you need to log in
How to fix encoding bug when exporting to CSV?
public function actionTest(){
$content = '"Привет мир";"test"';
$this->stream($content, 'contacts.cvs');
}
private function stream($content, $name){
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.$name);
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: '.strlen($content));
echo $content;
exit();
}
function remove_utf8_bom($text){
$bom = pack('H*','EFBBBF');
$text = preg_replace("/^$bom/", '', $text);
return $text;
}
Answer the question
In order to leave comments, you need to log in
This is a problem in Excel itself - google how to properly open Excel files in UTF-8 (through data import, in my opinion).
artkiev.com/blog/excel-import-csv-utf-8.htm
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question