From 83494f6897ad0d817aa586e2849bdc2661ceab3e Mon Sep 17 00:00:00 2001 From: Kevin <6500490+Zeturic@users.noreply.github.com> Date: Thu, 20 Apr 2023 15:15:09 -0400 Subject: [PATCH] simplify tradescantia's character decoding --- tools/tradescantia/encoding.py | 81 +++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 7 deletions(-) diff --git a/tools/tradescantia/encoding.py b/tools/tradescantia/encoding.py index db50bd4..71b0f15 100644 --- a/tools/tradescantia/encoding.py +++ b/tools/tradescantia/encoding.py @@ -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: @@ -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", }