Good morning StackOverflow! I'm immersed in a problem that I do not know very well how to solve in a "professional" way without doing a lot of code and getting my head in the thick of things.
I am sending a telegram to a team via TCP socket, I do the following;
byte [] mensaje = Encoding.Default.GetBytes(txtASCII.Text);
int bytesSent = envio.Send(mensaje);
The object "send" is instantiated from the class socket and it works perfectly for me but besides this I need to do something else, I need to send in the telegram any of the first 31 characters of control of the ascii code, that is, I need to send from Somehow a chain composed of normal ascii letters and also concatenate control characters and that the team finds out, the problem is that I must do it so that the user can put the chain in a coherent way (for him).
An example; If I send a normal string without control characters, it would be the following; 123ABC, which in decimal would be (49 50 51 65 66 67)
With this there is no problem because the chain I convert directly ...
But if for example the user wants to send a carriage return at the end of the telegram he would write it in this way (to put some coherent) 123ABC (CR), actually I should send the previous code plus the 13 that is the CR but I can not do the direct conversion since I would convert what I do not want "(CR)"
I do not know if I explained myself well ... Can you think of a way to do it cleanly?
P.D: I edit the message to add ... The interesting thing would be to control at all times where the control characters are, since it is possible to put several in the same telegram; 123ABCD (CR) (LF), for example ...
Thank you very much