how can I clear out null characters in a string var?
-
I read in a chunk of a file in bytes, converted it to ascii, made it a string and now I am trying to clear out the '\0' characters. Any advice?
The simplest single-line call is to do this:
<your string>.Replace('\0'.ToString(), ""));
or<your string>.Replace("\0", ""));
I would probably recommend stripping unneeded chars as you're reading in the bytes, or when you convert to ascii, if you're doing that work yourself and can find a good place to insert the logic; it'd probably be faster that way. -Jeff here, bloggy bloggy -
The simplest single-line call is to do this:
<your string>.Replace('\0'.ToString(), ""));
or<your string>.Replace("\0", ""));
I would probably recommend stripping unneeded chars as you're reading in the bytes, or when you convert to ascii, if you're doing that work yourself and can find a good place to insert the logic; it'd probably be faster that way. -Jeff here, bloggy bloggy