Hello Using the PhpOffice (PhpSpreadsheet) library PhpOffice (PhpSpreadsheet) , I PhpOffice (PhpSpreadsheet) data to a csv file. Problem: instead of Cyrillic, "krakozyabry" are displayed in the generated file. mb_detect_encoding indicates that this data is in ASCII , but mb_convert_encoding($my_str, "ASCII", "UTF-8")) does not help, only the "curving" format changes. csv file settings:

  header('Content-Encoding: UTF-8'); header('Content-type: text/csv; charset=UTF-8'); header('Content-Disposition: attachment; filename=Customers_Export.csv'); header('Pragma: no-cache'); header('Expires: 0'); 

Tell me which way to dig. thank

  • And can you see an example of gibbering? - Bolverkr Eldjarnson am

1 answer 1

Because the mb_convert_encoding($my_str, "ASCII", "UTF-8") string mb_convert_encoding($my_str, "ASCII", "UTF-8") converts data from UTF-8 to ASCII , these values ​​need to be swapped. Read the documentation carefully.

 mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding = mb_internal_encoding() ] ) : string 

https://www.php.net/manual/ru/function.mb-convert-encoding.php

  • one
    Thanks, but does not help, all the same krakozyabry. with icov also tried just in case - Roma Tulaydan