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

后端 未结 27 2060
醉梦人生
醉梦人生 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 23:10

    As I posted on http://thinkinginsoftware.blogspot.com/2017/12/correctly-generate-csv-that-excel-can.html:

    Tell the software developer in charge of generating the CSV to correct it. As a quick workaround you can use gsed to insert the UTF-8 BOM at the beginning of the string:

    gsed -i '1s/^\(\xef\xbb\xbf\)\?/\xef\xbb\xbf/' file.csv
    

    This command inserts the UTF-4 BOM if not present. Therefore it is an idempotent command. Now you should be able to double click the file and open it in Excel.

提交回复
热议问题