gpt4 book ai didi

javascript - jQuery DataTables CSV 导出 utf-8

转载 作者:行者123 更新时间:2023-12-01 00:55:38 26 4
gpt4 key购买 nike

我想将数据表导出为 CSV。如何指定utf-8编码?

http://jsfiddle.net/ebRXw/3058/

Mamadou Diôf 导出后成为 Mamadou Di´f

我尝试添加 "bom":true 但问题仍然存在

最佳答案

将 bom 放入 csv 扩展选项中:

$(document).ready(function() { 
var dataSet = [
[ "Tiger Nixon", "System Architect", "Edinburgh", "5421", "2011/04/25", "$320,800" ],
[ "Garrett Winters", "Accountant", "Tokyo", "8422", "2011/07/25", "$170,750" ],
[ "Mamadou Diôf", "Junior Technical Author", "San Francisco", "1562", "2009/01/12", "$86,000" ]
];

$('#example').DataTable( {
dom: 'Bfrtip',
data: dataSet,
columns: [
{ title: "Name" },
{ title: "Position" },
{ title: "Office" },
{ title: "Extn." },
{ title: "Start date" },
{ title: "Salary" }
],
buttons: [
{
extend: 'csv',
charset: 'UTF-8',
fieldSeparator: ';',
bom: true,
filename: 'CsvTest',
title: 'CsvTest'
}
]
});
});

关于javascript - jQuery DataTables CSV 导出 utf-8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44547622/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com