Solved

StreamReader reading unicode characters

Posted on 2007-03-30
3
3,054 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 62

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
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…

777 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