SFML community forums

Help => Graphics => Topic started by: Cadisol87 on September 21, 2014, 04:16:32 pm

Title: Render special characters from a variable
Post by: Cadisol87 on September 21, 2014, 04:16:32 pm
I want to render a sf::Text, which contains special characters.
I know that if the text wouldn't be a variable, I could do somenthing like this:
text.setString(L"öüäßê");
But in my case, the text is entered by the user.
How can I render the sf::Text, without having to use a switch statement to check if the character the user entered is a special one?
Title: Re: Render special characters from a variable
Post by: Nexus on September 21, 2014, 06:08:32 pm
In what format is the text entered by the user? What data type do you use?

If you use TextEntered event -- as you should if the SFML window is accepting user input -- then you have a sf::Uint32 value representing the character. You can append it to an sf::String object, and then pass that string to sf::Text.
Title: Re: Render special characters from a variable
Post by: Cadisol87 on September 21, 2014, 08:25:44 pm
Thanks :)
I tried to get the character as a char and then append it to a std::string at first, but now it works perfect.