Search code examples
javascriptjsonexcelcsvpapaparse

Add byte order mark to CSV parsed via PapaParse


I'm using PapaParse in my application that converts JSON data to CSV then downloads it for the user. The problem is that my data is encoded in UTF-8 so when I open up the exported in Excel (without going through the text wizard), it assumes ASCII.

I found a similar SO question that suggests using a byte order mark and was curious on the correct way of adding this so that Excel recognizes the UTF-8 encoding.

Apologies for not having any codes samples, I'm not even quite sure where to start.

Thanks in advance!


Solution

  • I found the solution here: https://forums.meteor.com/t/solved-export-as-excel-csv/1191/25

    I simply prepended the BOM to the beginning of the CSV text string