Because my program does not generate CSV in UTF-8 that can be read correctly by Excel, but notepad generates

3

I have generated .CSV files in javascript , in UTF-8, but they are not read with correct encoding in Microsoft Excel (generating invalid characters instead of accented ones, as if I had read ISO 8859-1 or something like this).

Most competitors (Google Docs, LibreOffice, etc.) open a window where you can choose the correct encoding. And then I got to workaround with a stackoverflow response in English linking to another forum ( link )

Simply (according to this solution, which worked for me) when saving as UTF-8 inside the windows notepad (notepad), Excel magically recognizes the correct encoding as if there were some metadata. There is a combobox in the notepad that allows the choice of the UTF-8 encoding.

If the notepad can save a utf8 that Excel can read, can my program do it, too? If not, why saving by notepad works?

Note: I have generated UTF-8 because I have needed to use Node.js and Phantom.js and these technologies give more support to writing text file in UTF-8.

    
asked by anonymous 29.08.2016 / 22:35

1 answer

0

Try to start your file with \ ufeff.

This is UTF-8's BOM (Binary Byte Order) tag.

    
03.11.2016 / 20:09