简单文本文件处理
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();
}
}