djfz-2023-s464933/TaskG04/run.py

21 lines
482 B
Python

import re
import sys
def binary_to_utf8(binary_string):
bytes_list = [binary_string[i:i+8] for i in range(0, len(binary_string), 8)]
decimal_list = [int(byte, 2) for byte in bytes_list]
bytes = bytearray(decimal_list)
try:
utf8_text = bytes.decode('utf-8')
except UnicodeDecodeError:
utf8_text = bytes.decode('utf-8', errors='replace')
return utf8_text
for line in sys.stdin:
result = binary_to_utf8(line.strip())
print(result)