3
Answers

How to skip/ignore null(\0) chars when reading streamed data from sockets?

periakaruppan_sg

periakaruppan_sg

19y
3.4k
1
Hi, My C# application is getting data stream from remote server. After getting receiving the data from socket, i am converting it to "String" thru the ASCII encoder(Encoder.GetString()). In the streamed data, there are some "null" characters which is indicated as '\0'. I do not know how these chars are coming with the stream. But, the streamed data is perfectly correct data and i have checked that. I am supposed to skip those null characters and read the subsequent characters. The problem i am facing now is that the embedded '\0' characters are getting mixed with the "Date" fields and thus invalidating the "Date". How to resolve this? i.e. How to skip/ignore the embedded '\0' chars in the stream. Am i making any mistake with encoders... ASCII... UTF...or something else? Hope you guys can help me resolve this. Thanks in advance. Regards, Peri
Answers (3)