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

  • Thread starter Thread starter R.A.M.
  • Start date Start date
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/
 
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.
 
Back
Top