473,386 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Trimming Nulls from array

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
Nov 20 '05 #1
1 2646
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

"ZorpiedoMan" <js******@dscicorp.com> wrote in message
news:Oc**************@TK2MSFTNGP11.phx.gbl...
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

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
0
by: Rhino | last post by:
I am working with SQL Functions in DB2 for Windows/Linux/UNIX (V8.2.1) and am having a problem setting input parameters for SQL Functions to null in the Development Center. My simple function,...
13
by: jt | last post by:
I can't seem to find a way to concatenate strings that have nulls within the string. I have a string that I need another string that has nulls in it and what to append the 2nd string, 3 string...
5
by: Drew | last post by:
I have been using System.Text.Encoding.Unicode.GetString(byte,0,72) to converter a byte array from the registry to a string. This works, but I end up with a bunch of null characters after the...
1
by: buc | last post by:
I have created a byte array (1000 in size) to recv a network packet. I recv the packet, which varies in size, and need to put the packet in a string; so I can append another string after the packet...
8
by: rayw | last post by:
Following on from my post yesterday about nums -> binary strings ... I've written two routines that can trim the leading zeros from the results, so I call either of these like this: char *...
0
by: Paul | last post by:
On my local site, I have a folder that is security trimmed, so that only members of a Role can see it after they register and log on (I set the memberships). All works fine locally. However,...
13
by: Angus | last post by:
Hello I have a stream of bytes - unsigned char*. But the 'string' may contain embedded nulls. So not like a traditional c string terminated with a null. I need to calculate the length of...
1
by: =?Utf-8?B?ai5hLiBoYXJyaW1hbg==?= | last post by:
Hello, I've eliminated the bulk of code, this should be sufficient: byte fromEncrypt; string sDecryptedString; //Read the data out of the crypto stream. csDecrypt.Read(fromEncrypt, 0,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.