f | import sys | f | import sys |
n | encodings = ['koi8-r', 'cp1251', 'mac-cyrillic', 'cp866', 'iso8859-5', ' | n | encodings = ['KOI8-R', 'CP1251', 'MACCYRILLIC', 'CP866', 'ISO-8859-5', ' |
| cp855'] | | CP855'] |
| text_bytes = sys.stdin.buffer.read() | | line = sys.stdin.buffer.read() |
| done = False | | to_break = False |
| for encoding1 in encodings: | | for first_encoding in encodings: |
| if done: | | if to_break: |
| break | | break |
| try: | | try: |
n | decoded = text_bytes.decode(encoding1) | n | decoded = line.decode(first_encoding) |
| for encoding2 in encodings: | | for second_encoding in encodings: |
| if done: | | if to_break: |
| break | | break |
| try: | | try: |
n | encoded = decoded.encode(encoding2) | n | encoded = decoded.encode(second_encoding) |
| for encoding3 in encodings: | | for third_encoding in encodings: |
| try: | | try: |
t | result = encoded.decode(encoding3) | t | decoded2 = encoded.decode(third_encoding) |
| if 'Зимбабве' in result: | | if 'Зимбабве' in decoded2: |
| print(result) | | print(decoded2) |
| done = True | | to_break = True |
| break | | break |
| except: | | except: |
| pass | | pass |
| except: | | except: |
| pass | | pass |
| except: | | except: |
| pass | | pass |