Craig Klinker <(E-Mail Removed)> wrote:
> I am having an issue trying to use a binary reader. In the following case I
> would like to have the value 66 and 3 returned respectivly but I am getting
> large number since the reader is reading in littleendian format.
>
> Here is my code
>
> Dim Buffer() As Byte = New Byte() {&H0, &H0, &H0, &H42, &H0,
> &H0, &H0, &H3}
> Dim ms As New IO.MemoryStream(Buffer)
> Dim br As New IO.BinaryReader(ms,
> Text.Encoding.BigEndianUnicode)
> Console.WriteLine("Message Length = " & br.ReadInt32())
> Console.WriteLine("Message Type = " & br.ReadInt32())
>
> This generates
>
> Message Length = 1107296256
> Message Type = 50331648
>
>
>
> Does anyone know of an easy way to accomplish this or so I have to write my
> own encoder?
Basically you need a version of BinaryReader which allows you to
specify the endianness. I've considered writing such a class before -
if you'd like me to do it for you, just let me know.
--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too