eligrey / eligrey/FileSaver.js

AutoBom not working properly ?

Open
#596 6 comments 15 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22k
Forks
4.3k
PR merge metrics
No merged PRs in 30d

Description

Hi , i'm trying to export a csv and be able to open it in ms excel. To do that i need to add the UTF8 BOM ...
From what i undestand this should be enough :

```
const blob = new Blob([csv], {type: 'text/csv;charset=utf-8'}); // csv being a string
const filename = this.srv.label + '_' + type + '_archives.csv';
saveAs(blob, filename, { autoBom: true });
```

But the result is an utf8 file without bom. If i manualy append the BOM like this
`const blob = new Blob([String.fromCharCode(0xFEFF), csv], {type: 'text/csv;charset=utf-8'});`
it's working perfectly.

Any idea ? Should i always append manually the BOM ?

Using FileSaver 2.0.2. Tested on Firefox.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.