C#:缅甸字体数据的 Excel 导出无法正确显示



我正在尝试将数据表数据作为CSV文件获取。但是缅甸字体的数据在excel中显示不正确。它显示为以下字符。

"™™";我附上了我的代码。

DataTable dt = ToDataTable(objList);
StringBuilder sb = new StringBuilder();
IEnumerable<string> columnNames = dt.Columns.Cast<DataColumn>().
Select(column => column.ColumnName);
sb.AppendLine(string.Join(",", columnNames));
foreach (DataRow row in dt.Rows)
{
IEnumerable<string> fields = row.ItemArray.Select(field => field.ToString());

sb.AppendLine(string.Join(",", fields));
}
string folderPath = HttpContext.Current.Server.MapPath("/Files") + "/Files/Export/";
File.WriteAllText(folderPath + "Export.csv", sb.ToString());

更换

File.WriteAllText(folderPath + "Export.csv", sb.ToString());

File.WriteAllText(folderPath + "Export.csv", sb.ToString(), Encoding.Unicode);

根据https://www.unicode.org/faq/myanmar.html#:~:text=A%3A%20Myanmar%20script%20was,在%202009中扩展了%20script+20。

缅甸语脚本在3.0版(1999年9月(中被添加到Unicode标准中。5.2版显著扩展了2009年中的脚本

最新更新