Skip to content

Commit

Permalink
simplify tradescantia's character decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeturic committed Apr 20, 2023
1 parent 030d081 commit 83494f6
Showing 1 changed file with 74 additions and 7 deletions.
81 changes: 74 additions & 7 deletions tools/tradescantia/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ def decode(bytestring):
for byte in bytestring:
if byte in decode.dictionary:
chars.append(decode.dictionary[byte])
elif 0xBB <= byte <= 0xD4:
chars.append(chr(byte - 0xBB + ord("A")))
elif 0xD5 <= byte <= 0xEE:
chars.append(chr(byte - 0xD5 + ord("a")))
elif 0xA1 <= byte <= 0xAA:
chars.append(chr(byte - 0xA1 + ord("0")))
elif byte == 0xFF:
break
else:
Expand All @@ -19,6 +13,79 @@ def decode(bytestring):

decode.dictionary = {
0x00: " ",
0xA1: "0",
0xA2: "1",
0xA3: "2",
0xA4: "3",
0xA5: "4",
0xA6: "5",
0xA7: "6",
0xA8: "7",
0xA9: "8",
0xAA: "9",
0xAB: "!",
0xAC: "?",
0xAD: ".",
0xB4: "'"
0xAE: "-",
0xB0: "…",
0xB1: "“",
0xB2: "”",
0xB3: "‘",
0xB4: "'",
0xB5: "♂",
0xB6: "♀",
0xB8: ",",
0xBA: "/",
0xBB: "A",
0xBC: "B",
0xBD: "C",
0xBE: "D",
0xBF: "E",
0xC0: "F",
0xC1: "G",
0xC2: "H",
0xC3: "I",
0xC4: "J",
0xC5: "K",
0xC6: "L",
0xC7: "M",
0xC8: "N",
0xC9: "O",
0xCA: "P",
0xCB: "Q",
0xCC: "R",
0xCD: "S",
0xCE: "T",
0xCF: "U",
0xD0: "V",
0xD1: "W",
0xD2: "X",
0xD3: "Y",
0xD4: "Z",
0xD5: "a",
0xD6: "b",
0xD7: "c",
0xD8: "d",
0xD9: "e",
0xDA: "f",
0xDB: "g",
0xDC: "h",
0xDD: "i",
0xDE: "j",
0xDF: "k",
0xE0: "l",
0xE1: "m",
0xE2: "n",
0xE3: "o",
0xE4: "p",
0xE5: "q",
0xE6: "r",
0xE7: "s",
0xE8: "t",
0xE9: "u",
0xEA: "v",
0xEB: "w",
0xEC: "x",
0xED: "y",
0xEE: "z",
}

0 comments on commit 83494f6

Please sign in to comment.