I haven't tested this but I think it's a step in the right direction... Change
the encoding of the StreamReader...
.......
using(StreamReader sr = ....){
sr.CurrentEncoding = System.Text.Encoding.Unicode;
var line = sr.ReadLine();
.......
}
I see this working unless you are having to deal with non-unicode characters
(not likely). There is also an Encoding.UTF32 property that uses 32 bits to
describe it's code page instead of 16 bits.
On Thu, Sep 4, 2008 at 5:48 AM, Glenn <[EMAIL PROTECTED]> wrote:
> Without running some tests, I'm only guessing here. I suspect that
> StreamReader is treating the data as text. Try using a BinaryReader instead
> to filter out the data.
>
> ...Glenn
>
> On Wed, Sep 3, 2008 at 1:23 PM, Andrew <[EMAIL PROTECTED]> wrote:
>
>>
>> Hi all, I am trying to read a text like file that is padded with some
>> garbage (or at least it is to me). When I try to read using
>> StreamReader it does not make it past the first few awkward
>> characters, can anyone suggest a method to read in this data? Simply
>> ignoring it is a acceptable solution, as the end result is to filter
>> this out.
>>
>>
>>
>> This is an example of what the input is like, everything before the
>> 0H## is garbage, but using StreamReader it does not get past them.
>>
>> µ á 0H12$HEHDT,224.71,T*1D
>> É á 0H14$WIMWV,009,R,023,N,A*2B
>> É á 0H15$VMVLW,301074.5,N,0296833,N*79
>> Ý á 0H23$AGHTD,V,3.9,R,R,N,10,10,0.5,10.0,,0.0,,T,A,A,A,224.7*6C
>> Ý á 0H12$HCHDM,232.90,M*13
>>
>> Here is the implementation of the code. Currently just dumps what is
>> read into a text box as proof of concept.
>>
>> myStream = opnFile.OpenFile()
>> If (myStream IsNot Nothing) Then
>> Dim objReader As New
>> StreamReader(opnFile.FileName)
>> txtOut.Text = objReader.ReadToEnd
>> objReader.Close()
>> 'Read stream
>> End If
>>
>>
>>
>> Any help greatly appreciated.
>>
>> Cheers and thanks.
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---