summaryrefslogtreecommitdiffstats
path: root/rust/vendor/brotli/research/frombase2.py
diff options
context:
space:
mode:
Diffstat (limited to 'rust/vendor/brotli/research/frombase2.py')
-rw-r--r--rust/vendor/brotli/research/frombase2.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/rust/vendor/brotli/research/frombase2.py b/rust/vendor/brotli/research/frombase2.py
new file mode 100644
index 0000000..b81cb9b
--- /dev/null
+++ b/rust/vendor/brotli/research/frombase2.py
@@ -0,0 +1,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))