Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1460

[VB6] Bytarr - String-style operations by wrapping a Byte array

$
0
0
People seem to get tangled up in their underwear a lot trying to fiddle with binary data in String variables. Often they run into nightmares where they convert Unicode "to Unicode" and then back later, in the vain hope of avoiding data corruption. And then some locale boundary gets crossed and it all falls down. Hard.

From what I've seen the bulk of this comes from the desire to use String operations on binary data. But most of these are fairly trivial to synthesize, especially with the help of CopyMemory.


The Bytarr Class wraps a dynamic Byte array along with several properties and methods to make this easier.

You can use the Class for lots of applications, or when you only need one or two operations it can server as a template for inline code when you don't want the Class.


Bytarr (biter?) is bundled with a test program in the attachment. This also includes my Dump Class, which I find handy for debugging and testing.

Name:  sshot.png
Views: 76
Size:  8.0 KB


There may be lingering bugs, but these should be easily found and fixed as required. You could also add more operations or convert the Class into a binary stringbuilder for better performance when you need to accumulate a lot of chunks into one array.
Attached Images
 
Attached Files

Viewing all articles
Browse latest Browse all 1460

Trending Articles