467,081 Members | 1,118 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

How to extract a string from a buffer ?

Hiya,

I need to extract a string (ascii) from a buffer, my buffer is

dim buf(1023) as byte

This buffer containg an "array" of type xxx

type xxx is defined in C as follows

typedef struct{
long x1
long x2
char text[0]
} xxx ;

The text field conaint a C style string zero (ascii), so although
I know the string begins at buf(8), i need to scan until I find
the zero to get the length. Then, there is a 32 bit alignment and
another xxx item, etc.

One idea which I thought about was while I am looking for the
zero, to build the string as follows:

s=s+chr(buf(i))

but this is going to be slow, is there some sort of other way,
something elegant and vb-atomic (i.e. without a for loop) ?
Nov 21 '05 #1
  • viewed: 1497
Share:
1 Reply
but this is going to be slow, is there some sort of other way,
something elegant and vb-atomic (i.e. without a for loop) ?


Call the GetString method on the appropriate System.Text.Encoding
subclass.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Sharon | last post: by
6 posts views Thread by Selen | last post: by
6 posts views Thread by giloosh | last post: by
14 posts views Thread by Aman JIANG | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.