0
This repository has been archived on 2025-04-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Minecraft-Overviewer/contrib/cyrillic_convert.py
2019-03-30 11:46:37 +00:00

94 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Convert gibberish back into Cyrillic"""
import fileinput
import argparse
import sys
gibberish_to_cyrillic = {
'À': 'А',
'Á': 'Б',
'Â': 'В',
'Ã': 'Г',
'Ä': 'Д',
'Å': 'Е',
'Æ': 'Ж',
'Ç': 'З',
'È': 'И',
'É': 'Й',
'Ê': 'К',
'Ë': 'Л',
'Ì': 'М',
'Í': 'Н',
'Î': 'О',
'Ï': 'П',
'Ð': 'Р',
'Ñ': 'С',
'Ò': 'Т',
'Ó': 'У',
'Ô': 'Ф',
'Õ': 'Х',
'Ö': 'Ц',
'×': 'Ч',
'Ø': 'Ш',
'Ù': 'Щ',
'Ú': 'Ъ',
'Û': 'Ы',
'Ü': 'Ь',
'Ý': 'Э',
'Þ': 'Ю',
'ß': 'Я',
'à': 'а',
'á': 'б',
'â': 'в',
'ã': 'г',
'ä': 'д',
'å': 'е',
'æ': 'ж',
'ç': 'з',
'è': 'и',
'é': 'й',
'ê': 'к',
'ë': 'л',
'ì': 'м',
'í': 'н',
'î': 'о',
'ï': 'п',
'ð': 'р',
'ñ': 'с',
'ò': 'т',
'ó': 'у',
'ô': 'ф',
'õ': 'х',
'ö': 'ц',
'÷': 'ч',
'ø': 'ш',
'ù': 'щ',
'ú': 'ъ',
'û': 'ы',
'ü': 'ь',
'ý': 'э',
'þ': 'ю',
'ÿ': 'я'
}
trans_table = {ord(k): v for k, v in gibberish_to_cyrillic.items()}
def convert(s):
return s.translate(trans_table)
if __name__ == '__main__':
description = """
If you have signs that should be Cyrillic, but are instead gibberish,
this script will convert it back to proper Cyrillic.
"""
parser = argparse.ArgumentParser(description=description)
parser.add_argument('file', metavar='markers.js')
args = parser.parse_args()
convert(args.markers_file)
for line in fileinput.input(files=markers_file, inplace=1):
print(convert(s), end='')