kennethjiang/js-file-download

adding to bom option.

luccafort opened this issue · 1 comments

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.

@lukaszflorczak @luccafort in release 0.4.6 now.