Android Question Zeroes on end of string?

Arf

Well-Known Member
Licensed User
Longtime User
I am trying to read a string out of an array that contains a string and a number of zero values thereafter.

B4X:
newbytes = GetSubArray(pk.pData, 16, 12)
                    UnitInfo.Serialnum = bc.StringFromBytes(newbytes,"UTF8")

results in
000000000055 with 4 squares behind it when looking at the debug watch window, and UnitInfo.Length reports as 16.

I would have thought Length should have been 12 and the zeroes would have been considered null terminations.

How can I get rid of them zeroes so UnitInfo.Serialnum will behave like a proper string?
 

Arf

Well-Known Member
Licensed User
Longtime User
Sorry, not been around till now.
The output from that is:

30303030303030303030353500000000
 
Upvote 0
Top