Thanks for the reply : )
I looked into it a bit more and the problem was that the program couldn't show understand any character wider than 0xFF when in a wide string, anything longer had to be manually added (for example wide_str += 0x43f;). I found a utf_8 decoder online and that solved the problem
![Smiley :)](https://www.sfml-dev.org/forums/Smileys/default/smiley.gif)
I think it only works if the source file is utf_8 encoded but I am not sure.
#include <SFML/Graphics.hpp>
#include <Windows.h>
//source: https://stackoverflow.com/a/3999597/22872825
std::wstring utf8_decode(const std::string &str)
{
if( str.empty() ) return std::wstring();
int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
std::wstring wstrTo( size_needed, 0 );
MultiByteToWideChar (CP_UTF8, 0, &str[0], (int)str.size(), &wstrTo[0], size_needed);
return wstrTo;
}
int main(){
auto context_settings = sf::ContextSettings();
auto window = sf::RenderWindow{ sf::VideoMode{{500, 500}}, "Hello World", sf::State::Windowed, context_settings};
window.setFramerateLimit(60);
auto font = sf::Font::openFromFile("C:\\Windows\\Fonts\\Arial.ttf").value();
auto text = sf::Text{ font };
std::string str = "привет";
std::wstring new_str = utf8_decode(str);
text.setString(new_str);
while (window.isOpen()){
while (auto event = window.pollEvent()) {
if (event.value().is<sf::Event::Closed>()){
window.close();
}
}
window.clear();
window.draw(text);
window.display();
}
return 0;
}