比如汉字“关键词”
gb2312的encode是 %B9%D8%BC%FC%B4%CA
utf-8的encode是%E5%85%B3%E9%94%AE%E8%AF%8D
我已知%B9%D8%BC%FC%B4%CA 如何得到%E5%85%B3%E9%94%AE%E8%AF%8D
ASP中如何将gb2312的encode 转换成utf-8的encode
答案:2 悬赏:50 手机版
解决时间 2021-03-27 07:59
- 提问者网友:战皆罪
- 2021-03-27 02:57
最佳答案
- 五星知识达人网友:荒野風
- 2019-09-21 08:52
List fileList = new List();
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));
}
}
试试吧,希望有用
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));
}
}
试试吧,希望有用
全部回答
- 1楼网友:有你哪都是故乡
- 2020-03-19 15:48
http://www.baidu.com/baidu?word=%e5%9c%a8%e7%ba%bfutf8%e8%bd%ac%e6%8d%a2&se=360se_8_dg&ie=utf-8
这个应该是你想要的吧
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯