编码从ANSI更改为UTF8 [英] encoding change from ANSI to UTF8

查看:97
本文介绍了编码从ANSI更改为UTF8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要用我的代码打开一个txt文件,但是该文件采用ANSI(windows 1255)编码,并将其转换为UTF-8.我该怎么做?

I need to open a txt file in my code, but this file is in ANSI (windows 1255) encoding, and convert it to UTF-8. How can I do that?

推荐答案

让我们快速完成:用
阅读
Let''s do it quickly: read it with
System.IO.StreamReader reader =
    new System.IO.StreamReader(fileName, System.Text.ASCIIEncoding.ASCII, false);

使用

System.IO.StreamWriter writer =
    new System.IO.StreamWriter(fileName, false, System.Text.UTF8Encoding.UTF8);



—SA



—SA


这篇关于编码从ANSI更改为UTF8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆