Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Writing text in other languages.  (Read 1139 times)

0 Members and 1 Guest are viewing this topic.

DoubleNy

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Writing text in other languages.
« on: January 10, 2017, 11:18:15 pm »
Hello, i am trying to write text in russian and romanian, but the letters are shown as " ? " , how cand i write in other languages whith different letters, not only latins ?
a part of my code :
...
        sf::Text menu[MAX_NUMBER_OF_ITEMS];
...
        if (language == 0) { //romanian
                menu[0].setString(L"Joacă");
                menu[1].setString("Opțiuni");
                menu[2].setString("Ieșire");
        }
        if (language == 1) { //russian
                menu[0].setString("Играть");
                menu[1].setString("Настройки");
                menu[2].setString("Выити");
        }
...

 
« Last Edit: January 10, 2017, 11:19:56 pm by DoubleNy »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10827
    • View Profile
    • development blog
    • Email
Re: Writing text in other languages.
« Reply #1 on: January 11, 2017, 12:29:32 am »
First you need to make sure that the font you're using actually supports the unicode letters that you want to use.
Then you need to make sure to use L"" as you do for your first string.
And finally, if you set the encoding of your source code file to UTF-8, you should be able to use the characters directly in your strings, so no &#<number> encoding anymore.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/