Android Question byte access after Array to String


Licensed User

i get a lot of data (binary) over a tcp connection. The Data comes with the byte Array.
Sub Network_NewData(Buffer() As Byte)
End Sub

This Array then i append to a String-"buffer" like:
MyString = MyString + BytesToString(Buffer, 0, Buffer.Length, "Windows-1252")

after this i parse the string and want to extract the informations. This are encodet like:
<Unsigned Byte><Unsigned Byte>[<Data Byte(s)>]

as example (native Hex Values)
00 04 54 65 73 74

The first 2 bytes are the len of the message, the last are the message ("Test") itself.

So .. my first try was to create a lot of arrays where the data sored into and parse, use temp array, redim, merge remove, extract and copy the stuff around the array's. but, i can't believe that this are so compilcated.

So i want to manage this a lot ... smother .. with a simple string manipulation with the build-in string-commands.
But, i have the problem with the encoding's. How can access the native Byte by index-number in the String (like a pointer-access)?

Print MyString[3] 'for the 4. native unsigned Byte in the string

How i can do this? (i know, that a function exist what this "protocol" use, but i can't use it. This here is only a example. My Protocol is more compilcated and the "existing" isn't usable in my case)



Licensed User
yeah ... but, the array-managment is very complex as a string-managment .. missing "redim preserve" blows up the source so much.

so ... does not a other option exist, to solve this?
Upvote 0