//Now I define a Chinese string:'您好', and I want to download it and save to a file
var str="data:text/csv;charset=gbk" + encodeURI('您好');
//set a link for download
var link = document.createElement("a");
link.setAttribute("href", str);
link.setAttribute("download", ''filename'');
document.body.appendChild(link);
//click to download
link.click();
如果我下载并将其保存到文件中,它将由utf8编码,但我想通过gbk对其进行编码。
谢谢!