Trimming Nulls from array

  • Thread starter Thread starter ZorpiedoMan
  • Start date Start date
Z

ZorpiedoMan

I'm doing a bit of encoding and decoding.

When the encoding process ends, the result is a byte array with trailing
nulls (0's). Is there a simple way to rid myself of these?

Ex -

I encode the word "Password" (8 chrs in length) The result is a byte array
with a length of 16. When i decode it, I get a byte arraw that is also a
length of 16, the first 8 are the word Password, the next 8 are all zeros.

I'm basically looking for a "trim" function for a byte array...


-js
 
by the way, this is my solution, but it seems silly -


return Trim(Replace(Encoder.GetString(myUserName), Chr(0), Chr(32)))



myUserName is the ByteArray, Encoder is an instance of the ASCIIEncoding
class.



-js
 
Back
Top