码迷,mamicode.com
首页 > 其他好文 > 详细

简单文本文件处理

时间:2018-12-18 15:53:01      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:english   char   reader   for   open   from   bsp   pen   文本   

 

 

int chfrom = Convert.ToInt32("4e00", 16); //范围(0x4e00~0x9fff)转换成int(chfrom~chend)
int chend = Convert.ToInt32("9fff", 16);

using (FileStream fsFile = new FileStream(@"english.txt", FileMode.Open))
{
StreamReader srReader = new StreamReader(fsFile);

while (-1 != srReader.Peek())// or try "sr.Peek>=0"
{
string strLine = srReader.ReadLine();

string strEnglish = "";
string strChinese = "";
int code = 0;
for (int i = 5; i < strLine.Length; i++)
{
code = Char.ConvertToUtf32(strLine, i);
if (code >= chfrom && code <= chend)
{
strEnglish = strLine.Substring(0, i);
strChinese = strLine.Substring(i, strLine.Length - i);
break;
}
}
Console.WriteLine(strEnglish);

Console.ReadLine();
Console.WriteLine(strChinese);
Console.ReadLine();
}

}

简单文本文件处理

标签:english   char   reader   for   open   from   bsp   pen   文本   

原文地址:https://www.cnblogs.com/chenqingwei/p/10136999.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!