streamreader ignores Ascii 144

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

Guest

I am reading in a file line by line using a stream reader. When it hits a
record that has the following character: É, it drops that position out of
the stream entirely. I beleive, according to asciitable.com, that the É is
an extended ascii character (144.) Does anyone know why the streamreader
drops this character from a line when it's reading it and if there is a
possible workaround?
 
mfm said:
I am reading in a file line by line using a stream reader. When it hits a
record that has the following character: É, it drops that position out of
the stream entirely. I beleive, according to asciitable.com, that the É
is
an extended ascii character (144.) Does anyone know why the streamreader
drops this character from a line when it's reading it and if there is a
possible workaround?

There is no ASCII code 144 because ASCII is a 7-bit encoding (character
codes 0 to 127). It's likely that the file has been saved using another
encoding. You can try to read the file by passing
'System.Text.Encoding.Default' (the current Windows ANSI codepage) to the
'StreamReader' object's constructor. Nevertheless, you need to know which
encoding has been used when saving the file in order to decode the file
correctly.
 
I am reading in a file line by line using a stream reader. When it
hits a record that has the following character: É, it drops that
position out of the stream entirely. I beleive, according to
asciitable.com, that the É is an extended ascii character (144.)
Does anyone know why the streamreader drops this character from a line
when it's reading it and if there is a possible workaround?


Try changing the stream's encoding type? Perhaps manually specify ASCII?
 
You're right, the ascii code is greater than 127, it's 144, an 'extended'
ascii code. Can you point me to a resource that talks more about how to set
the encoding type of the stream reader?
 
mfm said:
You're right, the ascii code is greater than 127, it's 144, an 'extended'
ascii code. Can you point me to a resource that talks more about how to
set
the encoding type of the stream reader?

It's as simple as 'Dim sr As New StreamReader(<path>, <encoding>)', where
'<encoding>' is the appropriate 'System.Text.Encoding'.
 
Back
Top