{}
run-icon
main.py
def encode_mac_decode_shiftjis(text): # Encode in Macintosh mac_encoded = text.encode('macintosh', errors='replace') print(f"Macintosh Encoded Bytes: {mac_encoded}") # Decode in Shift_JIS mojibake = mac_encoded.decode('shift_jis', errors='replace') print(f"Mojibake (Macintosh -> Shift_JIS): {mojibake}") def encode_shiftjis_decode_mac(text): # Encode in Shift_JIS shift_jis_encoded = text.encode('shift_jis', errors='replace') print(f"Shift_JIS Encoded Bytes: {shift_jis_encoded}") # Decode in Macintosh mojibake = shift_jis_encoded.decode('macintosh', errors='replace') print(f"Mojibake (Shift_JIS -> Macintosh): {mojibake}") def main(): print("Choose an option:") print("1: Encode Lily Mojibake") print("2: Decode Lily Mojibake") choice = input("Enter your choice (1 or 2): ") text = input("Enter the text to encode and decode: ") if choice == "1": encode_shiftjis_decode_mac(text) elif choice == "2": encode_mac_decode_shiftjis(text) else: print("Invalid choice. Please run the program again and choose 1 or 2.") if __name__ == "__main__": main()
Output