kennethjiang / js-file-download

MIT License
915 stars 119 forks source link

adding to bom option. #37

Closed luccafort closed 5 years ago

luccafort commented 6 years ago

Hi! i want to blob data include bom. because i created csv file include garbled characters Japanese.

i want to this code to be changed like this.

module.exports = function(data, filename, mime, bom=null) {
    if (bom !== null) {
        data = [bom, data]
    } else {
        data = [data]
    }
    var blob = new Blob(data, {type: mime || 'application/octet-stream'});
    ...
}

// using sample.
var fileDownload = require('react-file-download');
var bom = new Uint8Array([0xEF, 0xBB, 0xBF]);
var mime = 'application/csv; charset=utf-8;';
fileDownload(data, 'filename.csv', mime, bom);

thanks.

kennethjiang commented 5 years ago

@lukaszflorczak @luccafort in release 0.4.6 now.