导出csv文件时韩文乱码解决方法

从asp.net导出csv这样配置可以防止韩文等乱码,在头部加上0xEF, 0xBB, 0xBF:

string fileName = "attachment;filename=" + HttpUtility.UrlEncode("文档");
Response.AppendHeader("Content-Disposition", httpHeader);
Response.ContentType = "text/csv"; 
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.HeaderEncoding = System.Text.Encoding.UTF8;
Response.BinaryWrite(new byte[] { 0xEF, 0xBB, 0xBF }); //Important!
Response.Write(sw);
Response.Flush();
Response.Close();

-

转载于:https://www.cnblogs.com/liqipeng/p/5644511.html

你可能感兴趣的:(导出csv文件时韩文乱码解决方法)