js-csv-encoding icon indicating copy to clipboard operation
js-csv-encoding copied to clipboard

Showcase of how to create valid CSV client-side

How to create a windows-1252 CSV

Microsoft Excel will open all CSV files with the windows-1252 encoding (also called ansi). Under certain circomstances (Microsoft Excel >= 2007 on Windows), an UTF-8 encoded CSV with BOM might be correctly opened.

You can find in this repository an example of how to generate a CSV encoded in windows-1252 directly in the browser. This example depends on two external projects:

text-encoding

The version in this repo is slightly modified one. The Encoding Living Standard does not specify how to encode to windows-1252, hence the modifications at the end of encoding.js and the call to CustomTextEncoder (with a special flag) instead of TextEncoder.

For more rational about this, see https://github.com/inexorabletash/text-encoding#non-standard-behavior.