I would like to convert a byte array containing non printable characters to string for my application. When I convert back to byte array, the contents of the array should remain the same as I found that ASCII/Unicode/UTF8 doesnt always give me the right solution?
E.g
byte[] bytearray ={ 147, 35, 44, 18, 255, 104, 206, 72 ,69};
string str = System.Text.Encoding.ASCII.GetString(bytearray);
bytearray = System.Text.Encoding.ASCII.GetBytes(str);
In the above example, I find that the byte array contains
{ 63, 35, 44, 18, 63, 104, 63, 72 ,69}.
Kindly help me.