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

Asked

Viewed 566 times

5

I have generated files .CSV in javascript, in UTF-8, but not read with the correct encoding in Microsoft Excel (generating invalid characters instead of accents, as if you were reading ISO 8859-1 or something like that).

Most competitors (Google Docs, Libreoffice, etc.) open a window in which it is possible to choose the correct encoding. And then I arrived at a workaround with a response from stackoverflow in English linking another forum (http://www.excelforum.com/excel-general/400043-csv-and-unicode-or-utf-8-problem.html)

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

If Notepad can save a utf8 that Excel can read, can my program also? If not, why does saving by Notepad work?

Note: I have generated in 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.

  • How are you generating csv? You’ve seen it here: http://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side

  • @Perrywerneck I think he’ll record this to the server / Node.js

  • Have you tried to see if the page encoding is also in UTF-8? There may be some page in the middle of the way with ANSI encoding... If it doesn’t, you can instead save the file in CSV, turn it into an HTML table as if it were a page and then save it with the XLS extension. So excel should open without problems

1 answer

2

  • It worked for me

Browser other questions tagged

You are not signed in. Login or sign up in order to post.