Ascii stream with missing bits (no parity)
<p>I've been given a task to look for 0's and 1's in a real textbook in order to decipher an ASCII message from it. The problem is that it's really hard to find all 0's and 1's and I have the feeling I am skipping a lot of them. This completely messes up the ASCII conversion. Some of the things I tried:</p>

<ul>
<li>'synchronize' words by detecting spaces (or something close to a space)</li>
<li>trying to correct chars based on assumption of only alphabet characters (a-z, A-Z)</li>
<li>trying to correct words based on the assumption of frequency of chars in the language (Dutch)</li>
</ul>

<p>But I still didn't get much out of it with the main problem being synchronization (when does a new char start?). I probably have to run through the books again (sigh, 3rd time or so) but I was wondering if you guys have any other ideas for the problem of missing bits in an ASCII binary stream?</p>

<pre><code>all_ones_and_zeros = re.findall("[01]",corpus_of_text)
BITS_PER_ASCII = 8 #(ascii characters are all the ordinals from 0-255 ... or 8 bits)
asciis = zip([iter(all_ones_and_zeros)]*BITS_PER_ASCII)
bins = [''.join(x) for x in asciis]
chars = [chr(int(y,2)) for y in bins]

print "MSG:",chars
</code></pre>

<p>I guess ... its not very clear what your input or expected output is ...</p>

python ascii parity