Is it possible to force Excel recognize UTF-8 CSV files automatically?

后端 未结 27 2092
醉梦人生
醉梦人生 2020-11-21 22:27

I\'m developing a part of an application that\'s responsible for exporting some data into CSV files. The application always uses UTF-8 because of its multilingual nature at

27条回答
  •  半阙折子戏
    2020-11-21 22:55

    In php you just prepend $bom to your $csv_string:

    $bom = sprintf( "%c%c%c", 239, 187, 191); // EF BB BF
    file_put_contents( $file_name, $bom . $csv_string );
    

    Tested with MS Excel 2016, php 7.2.4

提交回复
热议问题