hhurz / tableExport.jquery.plugin

jQuery plugin to export a html table to JSON, XML, CSV, TSV, TXT, SQL, Word, Excel, PNG and PDF
MIT License
984 stars 714 forks source link

BOM in CSV #368

Closed fvaletas closed 11 months ago

fvaletas commented 1 year ago

Hi,

BOM is never inserted in CSV exports.

The code is saveAs(blob, fileName, bom === false);

but FilSaver mentions :

FileSaver saveAs(Blob/File/Url, optional DOMString filename, optional Object { autoBom })

_Pass { autoBom: true } if you want FileSaver.js to automatically provide Unicode text encoding hints (see: byte order mark). Note that this is only done if your blob type has charset=utf-8 set._

https://github.com/hhurz/tableExport.jquery.plugin/issues/27

hhurz commented 1 year ago

Thanks for pointing this out. FileSaver did indeed change the BOM parameter of the saveAs function from bool to object. But unfortunately they messed up their code in the process, so the BOM option is never respected when saving a blob. There are issues complaining about this on the FileSaver project page. There is also a pull request from 2022 that would fix the problem, but there is currently little activity in the FileSaver project. Furthermore, there is a known conflict between pdfmake and FileSaver when using both modules. I am now thinking about integrating a corrected version of the FileSaver code into the table export code to solve this problem. But this will take some time...

hhurz commented 1 year ago

FYI: Release 1.28.0 has been released which fixes this issue. There was no need to adopt the FileSaver sources. It is sufficient to manage the BOM itself and thus not to use the FileSaver implementation.

fvaletas commented 1 year ago

Thanks