Problem using ReadLine() with StreanReader

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I am using the object Stream Reader to read Files. The method ReadLine()
does not read the character ñ o Ñ.

What Can i do?

Helpme please

thanks

Macisu

It does not work

StreamReader sFile = new StreamReader(ASCIIEncoding.ASCII);

byte[] bytes =
System.Text.Encoding.ASCII.Getbytes(sFile.ReadLine(:ToCharArray());
s=System.text.Encoding.ASII.GetString(bytes);

s is wrong,

Ideas?
 
Hi Macisu:
Please try to use UTF8 encoding
==>StreamReader sFile = new StreamReader(ASCIIEncoding.ASCII);
to:
StreamReader sFile = new StreamReader(System.Text.Encoding
..UTF8);
 
Marcisu,
As Marshal suggets, ASCII does not include the ñ & Ñ characters, as ASCII is
a 7 bit encoding. You need an 8 or 16 bit encoding to read ñ & Ñ.

In addition to trying the UTF8 encoding I would recommend the Default
encoding, as that is the encoding that is specific under your Windows
Control Panels.

Something like:

| StreamReader sFile = new StreamReader(filename,
System.Text.Encoding.Default);

Hope this helps
Jay


| Hi
|
| I am using the object Stream Reader to read Files. The method ReadLine()
| does not read the character ñ o Ñ.
|
| What Can i do?
|
| Helpme please
|
| thanks
|
| Macisu
|
| It does not work
|
| StreamReader sFile = new StreamReader(ASCIIEncoding.ASCII);
|
| byte[] bytes =
| System.Text.Encoding.ASCII.Getbytes(sFile.ReadLine(:ToCharArray());
| s=System.text.Encoding.ASII.GetString(bytes);
|
| s is wrong,
|
| Ideas?
|
 
Back
Top