Problem to Unicode

  • Thread starter Thread starter HuaMin Chen
  • Start date Start date
H

HuaMin Chen

Guest
Dear,
Why can't I combine the Unicode lines by these codes?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CombineText
{
class Test
{
static void Main(string[] args)
{
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
string str1,str2="";
string line_hld = "";
int pos0=0,pos1;
//using (StreamReader sr = new StreamReader(@"e:/t5.txt"))
using (StreamReader sr = new StreamReader(@"e:/t5.txt", Encoding.Unicode))
{
string line;
while ((line = sr.ReadLine()) != null)
{
if (line.Trim() == "")
{

}
else
{
//pos0 = line.Trim().IndexOf("[");
//pos1 = line.Trim().IndexOf("]", pos0 + 1);
//str1 = line.Substring(pos0 + 1, pos1 - 1 - pos0).Trim();
str1 = line;
//if (str2=="")
// str2=line.Trim();
// str2 = "'" + line.Trim() + "'";
// str2 = line.Trim().Substring(6);
//else
if (line_hld != line)
{
//pos0 = line.Trim().Length;
//str2=str2+";"+line.Trim().Substring(6);
//str2 = str2 + "," + "'" +line.Trim() + "'";
//str2 = str2 + ",'" + line.Trim()+"'";
//str2 = str2 + "," + line.Trim().Substring(pos0-3,3)+" - "+line.Trim().Substring(0,pos0-3);
//str2 = str2 + " " + line.Trim().Substring(pos0 - 3, 3);
//str2 = str2 + "," + str1;
str2 = str2 + "|" + str1;
//str2 = str2 + line.Trim();
}
}
line_hld = line;
}
}
using (StreamWriter sw = new StreamWriter(@"e:/t7.txt", true, Encoding.Unicode))
{
sw.WriteLine(str2);
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
}
}





Many Thanks & Best Regards, Hua Min

Continue reading...
 
Back
Top