n | import itertools | n | import codecs |
| import sys | | import sys |
| | | |
n | def decoder(text): | n | def decode_text(text): |
| for enc1 in ['KOI8-R', 'CP1251', 'MACCYRILLIC', 'CP866', 'ISO-8859-5 | | for enc1 in ['KOI8-R', 'CP1251', 'MACCYRILLIC', 'CP866', 'ISO-8859-5 |
| ', 'CP855']: | | ', 'CP855']: |
| for enc2 in ['KOI8-R', 'CP1251', 'MACCYRILLIC', 'CP866', 'ISO-88 | | for enc2 in ['KOI8-R', 'CP1251', 'MACCYRILLIC', 'CP866', 'ISO-88 |
| 59-5', 'CP855']: | | 59-5', 'CP855']: |
| for enc3 in ['KOI8-R', 'CP1251', 'MACCYRILLIC', 'CP866', 'IS | | for enc3 in ['KOI8-R', 'CP1251', 'MACCYRILLIC', 'CP866', 'IS |
| O-8859-5', 'CP855']: | | O-8859-5', 'CP855']: |
| try: | | try: |
n | text2 = text.decode(enc3).encode(enc2).decode(enc1) | n | re_text = text.decode(enc3).encode(enc2).decode(enc1 |
| | | ) |
| if 'Зимбабве' in text2: | | if 'Зимбабве' in re_text: |
| return text2 | | return re_text |
| except: | | except: |
| continue | | continue |
| return None | | return None |
| text = sys.stdin.buffer.read() | | text = sys.stdin.buffer.read() |
t | print(decoder(text)) | t | print(decode_text(text)) |