[UTILITY] CP1251 code converter

Andreman

Chieftain
Joined
Jun 15, 2020
Messages
14
Location
Belarus, Minsk
#russian localization
#cyrillic #cp1251

https://www.mediafire.com/file/tau20zgxob25oy4/CP1251_code_Converter.exe/file

When creating maps and Avatar mod, I ran into the problem that the world builder doesn't know how to save the Cyrillic symbols - it just breaks if it encounters it. Therefore, if I wanted the names of cities, etc. were still in Cyrillic - it was necessary to use the approach used by the game itself (for russian localization). Namely: Civilization 4 uses cp1251 encoding to display the Russian language. Moreover, each letter is designated by a digital code like Ï where 207 is the code, in this case, the letter П, in cp1251 encoding. Thus, to get the names inside the game in Cyrillic, you need to write them in this format. I rummaged through the Internet and did not find a converter that would allow you to quickly receive letter codes cp1251 - and manually writing by letter is a perversion. Therefore, I made a utility that converts text to code and back using the unity engine (it was easiest for me then). It worked inside the editor, but when assembled, firstly, for some reason the buttons did not work, and secondly, it weighed indecently a lot (50 mb). Nevertheless, it satisfied my personal modest needs. At the same time, of course, it was completely unportable.

In general, about three weeks ago, I decided to remake this utility for WinApi. It took a decent amount of time (learning about winapi itself, specifics of type conversions, encodings and applying regular expressions). Why I did this? Well, firstly, I just wanted to make a real utility, small and transportable, and not that quasi-monster. The second follows from the first - if anyone will make Russian-language (or, in principle, Cyrillic) versions of scenarious or mods himself: then this utility will be irreplaceable, in general I would like to share. And third, it was also interesting to see and understand a little about winapi. As a result, after dozens of hours (mainly studying the documentation), this utility is ready. Progress on the face - it weighs 80 kilobytes.

In general, I post it here, maybe someone will need it!)
(If you need it, be sure to write me reviews!)


При создании карт и своего мода (Аватар) я столкнулся с той проблемой что редактор не умеет сохранять кириллицу - он просто ломается если встречает её. Поэтому если я хотел чтобы названия городов и т.д. всё же были на кириллице - нужно было использовать подход, применяемый самой игрой. А именно: для отображения русского языка Civilization 4 использует кодировку cp1251. Причём каждая буква обозначается цифровым кодом вида Ï где 207 это код, в данном случае, буквы П, в кодировке cp1251. Таким образом чтобы получить названия внутри игры на кириллице нужно записать их в таком формате. Я перерыл интернет и не нашёл конвертера, который позволил бы быстро получать коды букв cp1251 - а вручную писать по букве - извращение. Поэтому я сделал утилиту которая конвертирует текст в код и обратно при помощи движка unity (мне тогда это было проще всего). Она работала внутри редактора, но в собранном виде, во-первых, почему-то не работали кнопки, а во-вторых, она весила неприлично много (50 мб). Тем не менее мои скромные потребности она удовлетворила. При этом конечно, она была совершенно нетраспортабельна.

Примерно в начала марта 2021 я решил переделать эту утилиту на WinApi. На это потребовалось приличное количество времени (изучение самого winapi, особенности преобразований типов, кодировок и применения регулярных выражений). Зачем я это делал? Ну, во-первых мне просто захотелось сделать реальную утилиту, небольшую и транспортабельную, а не тот квазимонстр. Второе вытекает из первого - может кто сам будет делать русскоязычные (или в принципе кириллические) версии сценариев или модов: тогда эта утилита будет незаменима, в общем я хотел поделиться. И третье - также было интересно посмотреть и немного разобраться в winapi. В итоге, после десятков часов (преимущественно изучения документации), эта утилита готова. Прогресс на лицо - она весит 80 килобайт.

В общем, выкладываю её тут, может она кому понадобится!)
(если она пригодилась - обязательно пишите мне отзывы!)

Upg. Screenshot added

 
Last edited:
From one developer to another good job. I am sure people will put it to good use.
 
Top Bottom