使用越南语将数据导出为CSV

问题描述 投票:0回答:2

我正在开发一个网站,允许将MSSQL中的数据导出到CSV文件,但我有一个麻烦,我的数据库包含越南语,所以当我将它导出到CVS文件。所有越南人都有错误!我怎么能用越南数据出口越南语而不会出错?这里是我的返回文件代码:

return File(new System.Text.UnicodeEncoding().GetBytes(str.ToString()), "text/csv", filename + DateTime.Now + ".csv");
c# export-to-csv cultureinfo culture
2个回答
0
投票

你有没有尝试过CultureInfo课程?像这样:

return File(new System.Text.UnicodeEncoding().GetBytes(str.ToString( new CultureInfo("vi"))), "text/csv", filename + DateTime.Now + ".csv");

0
投票

有效。

Response.ContentEncoding = System.Text.Encoding.Unicode; Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());

© www.soinside.com 2019 - 2024. All rights reserved.