ASP中如何将gb2312的encode 转换成utf-8的encode
发布网友
发布时间:2024-10-22 09:17
我来回答
共1个回答
热心网友
时间:2024-11-14 05:20
List<string> fileList = new List<string>();
fileList.Add(@"D:\test.txt");
foreach (var file in fileList)
{
byte[] bytes;
using (StreamReader reader = new StreamReader(file, Encoding.GetEncoding("gb2312")))
{
bytes = System.Text.Encoding.GetEncoding("gb2312").GetBytes(reader.ReadToEnd());
}
using (StreamWriter writer = new StreamWriter(file))
{
writer.Write(System.Text.Encoding.UTF8.GetString(bytes));
}
}
试试吧,希望有用