I use this method which I saw in one of the questions to convert ascii to binary string:
public string GetBits(string input)
{
StringBuilder sb = new StringBuilder();
foreach (byte b in ASCIIEncoding.UTF8.GetBytes(input))
{
sb.Append(Convert.ToString(b, 2));
}
return sb.ToString();
}
But, If the input is something like the message bellow which contains chars like 'space' or others:
"Hello, How are you?"
The above method is building a sequence of 6 or 7 bit. When I try to decode the long sequence(which I know every 8 bit is a character) I get a big problem that part of the message chars are 6 or 7 or 8 bit and everything is mixed up. How can I improve it? Thanks