|
Post by idolpx on Jun 5, 2006 13:48:07 GMT -5
Hi all.... I'm new to VBCorLib and was wondering if there was a class for dealing with binary strings of data. I've been working on a project and I deal with alot of different data and I know it's not good but I've been loading binary data into strings. If the reginonal settings of the system are set to use a multibyte character set things start messing up.
I know there has to be an easy way to do this. I just want to work with my raw binary data as if it were a string.
Any help would be greatly appreciated.
idolpx
|
|
|
Post by Kelly Ethridge on Jun 7, 2006 14:41:17 GMT -5
Hello,
I don't think I'm quite with you on what you're trying to do. What kind of data are you keeping in a String that you want to work with as binary data? I mean, what advantages are you having over using a Byte array? How do you want/need to deal with the String data? I'm sure I'm missing something.
Thanks, Kelly
|
|
|
Post by idolpx on Jun 14, 2006 5:14:53 GMT -5
I've written an HTTP transfer control and I'm getting the data as a string. It works great for downloading any type of file unless of course your system is set to use a multibyte character set. I need to convert it to use a byte array to fix this prob. It will also reduce the memory requirements alot as well. I'm just trying to figure out the best way to go about doing this without having to change alot of code. When I'm receiving data it does alot of string compares and parsing. Most of the time I'm just downloading HTML so it's ok. I just dread rewriting all of this and was hoping for a nonunicode string type of object. Then all I'd have to was change my strings to that type and all of my compares and parsing functions would still work on it. Wishful thinking huh? idolpx
|
|
|
Post by Kelly Ethridge on Jun 14, 2006 10:14:18 GMT -5
I understand now, thanks.
So how do you retrieve the data using HTTP? Do you use the INet control or handle that protocol manually using Winsock?
Kelly
|
|
|
Post by idolpx on Jun 15, 2006 2:42:57 GMT -5
I do everything manually using a modified cSocketMaster class from www.geocities.com/anshoku/It works great and like the winsock control I can receive the data as a byte array. As I receive data what's the best way to append data to my byte array buffer? ReDim Preserve and CopyMemory?
|
|
|
Post by Kelly Ethridge on Jun 15, 2006 11:59:45 GMT -5
Yes, that is a great socket class!
Now if you're getting everything in a byte array and just need to keep appending new byte array data to a buffer you could simply use the MemoryStream class in VBCorLib.
Dim data() As Byte Dim ms As New MemoryStream Do ' ... get data from socket ms.WriteBlock data, LBound(data), cArray.GetLength(data) Loop data = ms.ToArray
Once you have received all of the data, you can either read the data from the MemoryStream using other classes, or you can retrieve the entire byte array at once.
|
|
|
Post by idolpx on Jun 20, 2006 20:22:20 GMT -5
I'll try that. Thanks for the feedback.
I'm just now getting started with vbcorlib.
Very nice!!! It has alot of stuff in it that I use already just in a bunch of different class/module files.
I need to go through and start learning how to use each function in the library. I'm sure I could clean up alot of my code and replace it with compatible functions from vbcorlib.
idolpx
|
|