I am trying to print russian text in my SFML app, but I am only getting strange symbols. I know, that I can do:
text.setString(L"blabla")
However, I want to take text from the file. I use Unicode in my project. Screenshot:
For compatibility and simplicity you can use UTF8 to store the file. Read the file and then convert the UTF8 string. If you are saving the file in Notepad etc. then make sure it is saved in UTF8 format. If working with UTF16 files, you will run in to additional complications. ANSI format is outdated and not recommended.
#include <fstream>
#include <string>
#include <sstream>
...
std::ofstream fout(L"file.txt"); //Visual Studio allows wide char file name here
fout << u8"Test ελληνικά...";
fout.close();
std::ifstream fin(L"file.txt");
std::stringstream ss;
ss << fin.rdbuf();
std::string utf8 = ss.str();
sf::String str = sf::String::fromUtf8(utf8.begin(), utf8.end());