StreamReader reading unicode characters

I use the following code to open a text file.
StreamReader sr = File.OpenText(sFilePathName);
sr.ReadLine();
 
However the following was there in the text file with the unicode character, but the unicode character was chopped out
Revised list Home D├ęcor stores 6-10-05
This was read as
Revised list Home Dcor stores 6-10-05

Is there anyway I can read it the exact text with the unicode.


vasudharangapathyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Fernando SotoConnect With a Mentor RetiredCommented:
Hi vasudharangapathy;

The Encoding is the issue. File.Open only reads the file in UTF-8 encoding. Use the following to do what you need.

      StreamReader sr = new StreamReader(sFilePathName,System.Text.Encoding.Default);
      string input = sr.ReadLine();
      MessageBox.Show( input );
      sr.Close();

Fernando
0
All Courses

From novice to tech pro — start learning today.