summaryrefslogtreecommitdiffstats
path: root/rust/vendor/brotli/research/frombase2.py
blob: b81cb9b55aaf947fb5dfa4e11e47ad1aa70ef056 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import sys

result = []
cur_count = 0
cur_val = 0
for byte in sys.stdin.read():
    if byte == '1':
        cur_val |= (1<<cur_count)
    elif byte != '0':
        break
    cur_count += 1
    if cur_count == 8:
        result.append(chr(cur_val))
        cur_val = 0
        cur_count = 0
if cur_count != 0:
    result.append(chr(cur_val))
sys.stdout.write(''.join(result))