Skip to content

Instantly share code, notes, and snippets.

@ShawSumma
Created October 28, 2024 10:30
Show Gist options
  • Save ShawSumma/eae37b416c922ff678620a329a07ff99 to your computer and use it in GitHub Desktop.
Save ShawSumma/eae37b416c922ff678620a329a07ff99 to your computer and use it in GitHub Desktop.
# trying to solve this user's mojibake
# so far no encoding pairs or encoding quads have done it.
# https://www.reddit.com/r/softwaregore/comments/1gdlcjb/all_i_did_was_hit_print/
# Notes:
# * It's an all caps font.
# * It's encoding consistantly, E is always 8...
# * It feels ebcdic-ish, but not sure how.
from encodings.aliases import aliases
# uppercase only font, dont know which is right
txts = ['ZJ\\\\', 'Zj\\\\', 'zJ\\\\', 'zj\\\\']
done = {}
for k, v in aliases.items():
done[v] = k
# allt he unique encodings
enc1 = list(done.values())
enc2 = list(done.values())
# after one mojibake
done1 = set()
# after one or two mojibakes
done2 = {}
# calculate mojibakes
for txt in txts:
for src1 in enc1:
for dest1 in enc1:
try:
t1 = txt.encode(dest1).decode(src1)
except Exception as e:
continue
if t1 in done1:
continue
done1.add(t1)
done2[t1] = (dest1, src1)
for src2 in enc2:
for dest2 in enc2:
try:
v1 = t1.encode(dest2).decode(src2)
except Exception as e:
continue
v1 = v1.upper()
if v1 in done2:
continue
done2[v1] = (dest1, src1, dest2, src2)
# no unprintables
keys = {}
for key in done2.keys():
keys[''.join(i for i in key if i.isprintable())] = done2[key]
# in unicode order, becasue i love myself
for key in sorted(keys.keys()):
print(key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment