Microsoft Excel mangles Diacritics in .csv files?

后端 未结 22 1713
粉色の甜心
粉色の甜心 2020-11-22 05:02

I am programmatically exporting data (using PHP 5.2) into a .csv test file.
Example data: Numéro 1 (note the accented e). The data is utf-8 (

22条回答
  •  感情败类
    2020-11-22 05:29

    I've also noticed that the question was "answered" some time ago but I don't understand the stories that say you can't open a utf8-encoded csv file successfully in Excel without using the text wizard.

    My reproducible experience: Type Old MacDonald had a farm,ÈÌÉÍØ into Notepad, hit Enter, then Save As (using the UTF-8 option).

    Using Python to show what's actually in there:

    >>> open('oldmac.csv', 'rb').read()
    '\xef\xbb\xbfOld MacDonald had a farm,\xc3\x88\xc3\x8c\xc3\x89\xc3\x8d\xc3\x98\r\n'
    >>> ^Z
    

    Good. Notepad has put a BOM at the front.

    Now go into Windows Explorer, double click on the file name, or right click and use "Open with ...", and up pops Excel (2003) with display as expected.

提交回复
热议问题