Created
June 27, 2020 17:27
-
-
Save tripulse/630c5ce1077d01a2a6cdc367d0d75602 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bitstring import Bits | |
class SIGIO: | |
"""SIGIO is a binary-like format used by a person named 5IGI0 to interchange feelings. | |
The format is really limited to them and has no specification, with efforts of digging | |
it made this implementation possible.""" | |
@staticmethod | |
def encode(s): | |
return ''.join("'" if b else '-' for b in Bits(s.encode('ascii'))) | |
@staticmethod | |
def decode(s): | |
def to_bool(c): | |
if not c in "-'": | |
raise SyntaxError("invalid non-sigio character found") | |
return c == "-" | |
return Bits(to_bool(b) for b in s).tobytes().decode('ascii') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment