php - Yii2 always set header to "UTF-8 with BOM" for saving files -


in yii2 have controller save texts database .csv file. contains russian (cyrillic) language. problem when open file in excel, has bad charset: грузовÐ

for mac os , windows users excel charset result same. opening in notepad okey. notepad says has coding "utf-8 bom". if save "utf-8" notepad, excel reads .csv file.

code:

yii::$app->response->format = \yii\web\response::format_raw; yii::$app->response->charset = 'utf-8'; yii::$app->response->headers->set('content-type', 'text/csv; charset=utf-8'); yii::$app->response->headers->add('content-disposition', 'attachment; filename="myfile.csv"'); // header('content-type: text/plain; charset=utf-8',true); 

any ideas might wrong? tried lot of charsets (windows-1251, cp1251), text/plain -- no results. moreover, strange chars same if set charset chinese or other.

it headers charset not changed , "utf-8 bom".

yii::$app->charset 'utf-8', changing text/csv text/plain or text/json, or saving .txt , open in excel - same results.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -