n | import codecs | n | import itertools |
| import sys | | import sys |
| | | |
n | def decode_text(text): | n | def decoder(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 | re_text = text.decode(enc3).encode(enc2).decode(enc1 | n | text2 = text.decode(enc3).encode(enc2).decode(enc1) |
| ) | | |
| if 'Зимбабве' in re_text: | | if 'Зимбабве' in text2: |
| return re_text | | return text2 |
| except: | | except: |
| continue | | continue |
| return None | | return None |
| text = sys.stdin.buffer.read() | | text = sys.stdin.buffer.read() |
t | print(decode_text(text)) | t | print(decoder(text)) |