Filesaver.js: Can I save as UTF-8 Without BOM?

Created on 16 Jul 2015  路  6Comments  路  Source: eligrey/FileSaver.js

I am using the example:

var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
saveAs(blob, "hello world.txt");

I am replicating a historical system in a modern system. This downloaded as UTF-8. The Xml generated via the historical system saves as UTF-8 without BOM. I need it to be exactly the same encoding as the Xml I am trying to replicate.

Most helpful comment

Yeah, I just added a no_auto_bom argument to saveAs in the very latest version. Use saveAs(blob, name, true) to turn off the auto-BOM stuff.

I hadn't realized that some use cases might want the BOM stuff turned off when I first put that code in. Thanks for the bug report!

All 6 comments

Yeah, I just added a no_auto_bom argument to saveAs in the very latest version. Use saveAs(blob, name, true) to turn off the auto-BOM stuff.

I hadn't realized that some use cases might want the BOM stuff turned off when I first put that code in. Thanks for the bug report!

Thank you so much. I didn't realize the legacy system needed UTF-8 without BOM until the Xml didn't work and we scrambled to find the difference between the new system and the legacy system.

Glad I could help resolve your issue.

By the way. I tested it and can verify that it works. Notepad++ now shows the downloaded file encoding as UTF-8 without BOM.

Thanks a lot!

in case as export with chinese language you will have problem about font.

Was this page helpful?
0 / 5 - 0 ratings