[Close]
Welcome to SmG Gaming Community!
You're browsing our website as a Guest.
In order to view all of our content as well as added bonus features, please register by clicking HERE.
So I'm working on a ChatApp which uses Tcp Clients and Tcp Listeners.
So basically, I use NetworkStream to transfer data between the server and the client. The data is transferred in Bytes (byte []) and converted to String and displayed.
I use Encoding.ASCII.GetString() to convert it from bytes to String.
The problem is that when I convert bytes to string, the string contains null spaces, so I can't append text/ get substring of it.
Would be helpful if anyone can suggest a way to remove the null spaces or having the byte array size set to size of the string (in bytes) when receving from a stream.
Thanx in advance.
TLDR: Suggest a way to remove null spaces from string which use an encoder to convert byte array into string since data is transferred through networkstreams
(This post was last modified: 06 May 2017, 10:52 AM by FlasH™.)
I think null characters get translated to \0 in c#. So you should be able to use the replace function. Like string mystring = input.Replace("\0", string.Empty);
Do not meddle in the affairs of Dragons, for you are crunchy and taste good with ketchup!