djfz-2023-s464933/TaskG05/run.py

17 lines
433 B
Python

import sys
import binascii
def hex_to_utf8(hex_string):
hex_string = hex_string.replace(' ', '').replace('0x', '')
bytes_data = binascii.unhexlify(hex_string)
try:
utf8_text = bytes_data.decode('utf-8')
except UnicodeDecodeError:
utf8_text = bytes_data.decode('utf-8', errors='replace')
return utf8_text
for line in sys.stdin:
result_text = hex_to_utf8(line.strip())
print(result_text)