以latin1编码将下载缓冲区作为CSV表示为CSV

时间:2018-12-18 14:39:15

标签: node.js character-encoding export-to-csv

我正在尝试从UTF-8服务器将数据导出为CSV ISO-8859-1。

我正在使用此代码,它与char“ oe”不能正常工作

const express = require('express')
const app = express()

app.get('/', function (req, res) {
    const str = 'Bœuf été'
    res.set('Content-Type', 'application/csv')
    res.set('Content-disposition', 'attachment; filename=test.csv')
    res.send(Buffer.from(str, 'latin1'))
})

app.listen(3000, function () {
    console.log('listen on 3000')
})

在ISO-8859-1中,été的口音很好,但是Bœuf的编码不正确,我不知道自己在做什么错。

感谢您的帮助

0 个答案:

没有答案