Tuesday, February 12, 2013

MS Excel doesn't read UTF-8 CSV file correctly

I had an issue where MS Excel would not open CSV file generated in node.js in correct encoding. Instead of opening it with UTF-8 encoding it would use default ANSI encoding. To resolve this I had to add BOM at the beginning of a file. So my write file function would look like:


fs.writeFile(filename, '\ufeff' + data, 'utf8', function(err) {
    if (err) console.error(err);
});

This still doesn't resolved the issue MS Excel has, where it doesn't recognize C in CSV.

Reference:

  1. StackOverflow

No comments:

Post a Comment