Rendering non-Latin symbols

  • Buterbrod4495
    15th August Member 0 Permalink

    Hello. I've made a Russian translation for T.P.T., but the cyrillic element names and descriptions are not rendering correctly because they are probably interpreted as being in Latin-1 encoding, but my local russian save names have no such problem. I wonder how can I edit the code so element names and descriptions are rendered using the same method as the save names, i. e. in Unicode?

  • LBPHacker
    16th August Developer 0 Permalink
    Hi,
    1) make sure your source files are encoded with UTF-8,
    2) wrap every translated string literal in the ByteString constructor and call .FromUtf8() on the result, so like ByteString("...").FromUtf8() (can't insert Cyrillic because the forum is indeed Latin-1 lol)
    2a) if you would rather not do this and are willing to deal with the consequences of not taking care of the problem explained in the next paragraph, you can also just change the String([string literal]) constructor to use .FromUtf8() instead of .FromAscii() in String.h

    This also means that you have to convert every escape sequence in string literals to UTF-8 too, so e.g. "\x0F\xEF\xEF\020Click-and-drag to specify an area to create a stamp (right click = cancel)" would turn into ByteString("\x0F\xC3\xAF\xC3\xAF\020Click-and-drag to specify an area to create a stamp (right click = cancel)").FromUtf8() (and would then be translated).

    There's no guarantee in the C++ standard that just because your sources are UTF-8, your string literals also are, but it works with every compiler we care about and have tested.
    Edited 3 times by LBPHacker. Last: 16th August
  • Buterbrod4495
    16th August Member 0 Permalink

    It works, thank you so much! God bless you! :)