2.0: reading utf-8 text file with non-ASCII letters

R

R.A.M.

Hello,
Could you help me please with a problem of reading utf-8 file with
non-ASCII (Polish) letters? I have written such code:

DirectoryInfo D = new
DirectoryInfo(HttpContext.Current.Request.PhysicalApplicationPath);
foreach (FileInfo F in D.GetFiles("*.aspx"))
{
string S;
using (StreamReader R = new StreamReader(F.FullName, Encoding.UTF8))
while ((S = R.ReadLine()) != null)
...
}

The problem is that non-ASCII letters are ignored, for instance text
in Polish:
gór¹
is read:
S == "gr".

Could you tell me please how to solve the problem?
Thank you very much!
/RAM/
 
C

Chris Dunaway

If that is the case, then I would say that the file you are trying to
read is not UTF8 encoded. I'm not sure what encoding includes Polish
characters but I would think that is the encoding to use.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top