通过本文主要向大家介绍了streamreader中文乱码,streamreader 乱码,c streamreader 乱码,streamreader,streamreader.pe等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
相信很多人在读取文件的时候都会碰到乱码的情况,所谓乱码就是错乱的编码的意思,造成乱码的是由于编码不一致导致的。
演示程序:
新建3个文本文件:
编码和名字一样,分别是ansi,Unicode,utf8
里面的内容都是:
~!@#¥%……&*()
abcdefg
123456789
测试数据
读取这些文件的代码如下:
public static void Main()
{
List<string> lstFilePath = new List<string>()
{
"H:\\TestText\\ansi.txt",
"H:\\TestText\\unicode.txt",