当我保存CSV文件时,我得到了希伯来语的乱码,这是代码“我试图放入UTF-8,但仍然变得不合时宜。”
var data = [
['שם פרטי', 'programmer'],
['שם משפחה', 'bus driver'],
['כתובת', 'Reindeer Hunter']
];
function download_csv() {
var csv = 'Name, Title\n';
data.forEach(function(row) {
csv += row.join(',');
csv += "\n";
});
console.log(csv);
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:text/csv;charset=utf-8,' + encodeURIComponent(csv);
hiddenElement.target = '_blank';
hiddenElement.download = 'people.csv';
hiddenElement.click();
}