Last active
February 8, 2025 06:49
-
-
Save einstein95/073d89ca0aae1af7dea7dbd0250efc79 to your computer and use it in GitHub Desktop.
Very poor attempt at a Bank Street Writer (IBM PC) file decoder
This file contains hidden or 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
# Despite what's written about the Apple II version, the PC version of Bank Street Writer | |
# is a basic CGA word processor that uses ASCII-encoded files with some control codes. | |
# Files are stored without an extension, any files with an extension are password-protected. | |
# The extension is an encoded version of the password. Passwords are limited to 3 characters as a result. | |
import sys | |
control_codes = { | |
243: '{pb}', | |
244: '<c>', | |
245: '\t', | |
246: '{m}', | |
247: '<u>', | |
248: '<b>', | |
249: '</u>', | |
250: '</b>' | |
} | |
f = open(sys.argv[1], 'rb').read() | |
res = '' | |
for i in f: | |
if 31 < i < 0x80: | |
res += chr(i) | |
elif i == 0xD: | |
res += '\n' | |
elif i in control_codes: | |
res += control_codes[i] | |
else: | |
res += f'%{i:02X}%' | |
print(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment