ryu1kn / csv-writer

Convert objects/arrays into a CSV string or write them into a CSV file
https://www.npmjs.com/package/csv-writer
MIT License
246 stars 39 forks source link

unicode not working #61

Closed lehoangphan closed 3 years ago

lehoangphan commented 3 years ago

Although I use encode utf8, but data was written to file not has unicode

var writeCSV = async function(records) {
    const csvWriter = createCsvWriter({
        path: 'C:\\Users\\phan\\Desktop\\file.csv',
        header: [
            { id: 'stt', title: 'sothutu' },
            { id: 'barcode', title: 'mã' },
            { id: 'title', title: 'tựa' },
            { id: 'unit', title: 'đơn vị' },
        ],
        encoding: 'utf8'
    });
    let m = await csvWriter.writeRecords(records) // returns a promise
        .then(() => {
            console.log('...Done');
        });
}