17 lines
449 B
Python
17 lines
449 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.encode('utf-8'))
|