1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 [Solved] Issues with drawing Cyrillic text from a .ini file

Discussion in 'Programming' started by m4meteor, Jun 11, 2019.

  1. m4meteor

    m4meteor Member

    Joined:
    Apr 19, 2019
    Posts:
    6
    In my game I have setup a localization system using an included .ini file. The strings.ini file looks like this
    Code:
    [english]
    101=Resume
    102=Settings
    103=Quit
    104=Video
    105=Audio
    106=Controls
    107=Back
    108=Resolution
    109=Fullscreen mode
    110=Master
    111=SFX
    112=Music
    113=Walk left
    114=Walk right
    115=Jump
    116=Climb/Up
    117=Descend/Down
    118=General
    119=Language
    120=English
    121=Russian
    122=On
    123=Off
    
    [russian]
    101=Продолжить
    102=Настройки
    103=Выйти
    104=Видео
    105=Аудио
    106=Управление
    107=Назад
    108=Расшерение экрана
    109=Полноэкранный режим
    110=Мастер
    111=Эффекты
    112=Музыка
    113=Идти налево
    114=Идти направо
    115=Прыгать
    116=Подниматься/Вверх
    117=Спускаться/Вниз
    118=Основные
    119=Язык
    120=Англиский
    121=Русский
    122=Вкл
    123=Выкл
    Now in my game i have set-up a script, that looks like this
    Code:
    ///@desc string_lang(ini_index)
    ///@arg ini_index
    
    var search = argument0;
    
    switch (global.language)
    {
        case lang.english: var language = "english"; break;
        case lang.russian: var language = "russian"; break;
    }
    
    ini_open("strings.ini");
    var find_string = ini_read_string(language, string(search), "Error");
    ini_close();
    
    return find_string;
    
    So, now when I want to have a string translated to russian and english, for example, instead of putting
    Code:
    var text = "Resume"
    , I would put
    Code:
    var text = string_lang(101)
    Which would still be equal to "Resume" if global.language = lang.english but if global.language = lang.russian it would be equal to "Продолжить" which is the translation I want. Until here it is all ok, but when I get to print the string in Russian it prints boxes.

    Please note: I have a font that supports all Cyrillic letters and I have added a range for all the cyrrilic letters, yet still this problem happens. I also know that the problem isn't in the font because when I simply print a russian string without using the string_lang script it prints it perfectly.

    From my debug testing I know that the problem is when the string_lang reads the Russian strings from the .ini file. I know that because i've setup a variable be equal to string_lang(101) when language is Russian and from the debugger I can see that the variable is equal to "����������" instead of "Продолжить".

    Briefly:

    The problem is when I read a cyrillic string from a .ini file, Gamemaker returns it as strange boxes ("��������")

    How do I fix this?
     
    Last edited: Jun 11, 2019
  2. m4meteor

    m4meteor Member

    Joined:
    Apr 19, 2019
    Posts:
    6
    Oh i forgot to encode the .ini file to UTF-8 whhops my bad
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice