Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

StreamReader reading unicode characters

Posted on 2007-03-30
3
3,078 Views
Last Modified: 2013-11-07
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.


0
Comment
Question by:vasudharangapathy
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 18824254
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

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question