468,301 Members | 1,436 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,301 developers. It's quick & easy.

VB BinaryReader, reading Characters from stream

Hi, I have the following problem with my VB code: accented characters are
being transformed into a cr-lf pair!

I am reading a sequence of bytes from a binary file, one part of which is a
text string.
Here is a code snippet:

Dim fs As New FileStream("c:\test.bin", FileMode.Open)
Dim br As New BinaryReader(fs)
Dim str As String

str = br.ReadChars(10)
Debug.WriteLine(str)

if the test.bin file contains the characters 1234567890, there is no
problem: the output is
1234567890
but if it contains the text 12345à7890 then i get an output of :
12345
7890

Any accented character is turned into a cr-lf pair!
How can I read in a 10 byte binary sequence and store it as a string?

Thanks for any pointers,
James
Mar 28 '06 #1
2 1901
James,

You have to pass in the appropriate Encoding to the BinaryReader
constructor.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 29 '06 #2
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:uP**************@TK2MSFTNGP11.phx.gbl...
James,

You have to pass in the appropriate Encoding to the BinaryReader
constructor.

Mattias

Thanks for that,
James
Mar 29 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Kevin Trojanowski | last post: by
6 posts views Thread by Question with BinaryReader | last post: by
3 posts views Thread by =?Utf-8?B?VmljdG9y?= | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.