SFML community forums

Help => Graphics => Topic started by: GabrielS on June 13, 2013, 10:13:52 pm

Title: [SOLVED] Draw "not standard" char
Post by: GabrielS on June 13, 2013, 10:13:52 pm
Hello,

I want to draw some unusual characters like Ω. I know it is possible because when I do like this :

text.setString(L"Ω");

It works.
however, I want to do something much more like this :

string newText="blablaΩΩΩ";
text.setString(newText);

( Sorry for not putting the 'code part' not in between good tag but you can see just above that I had some issues displaying Ω in [ code ] tag. )
This displays '?' instead of 'Ω' . Is that possible to cast a string as a "L string" ? If so, how shall I do this ?

Thanks,

Gabriel
Title: Re: Draw "not standard" char
Post by: Nexus on June 13, 2013, 10:21:34 pm
std::wstring = L"blablaΩΩΩ"

Or directly use sf::String. By the way, as far as I know, the compiler isn't required to accept characters apart from ASCII directly in source code. For portability, you might therefore need the \x, \u or \U escape sequence.
Title: Re: Draw "not standard" char
Post by: GabrielS on June 13, 2013, 10:56:00 pm
hi,

Thanks for the fast answer.
However, std::wstring can't work for me because I'm using method needing 'std::string' argument.
I wanted to try with \u, it works, but I get the same character : instead of Ω , i get a '?' char

string resistorUnit = "M";
        resistorUnit.append("\u03A9");
        //mResistor->drawIn(window,font,"MO",COLOR_RESISTOR);
        mResistor->drawIn(window,font,resistorUnit,COLOR_RESISTOR);
Title: Re: Draw "not standard" char
Post by: FRex on June 13, 2013, 11:15:34 pm
If that is your code or you can change it, change it to use sf::String, if it's outside code, does it support UTF-8, if not, you're not getting that ohm symbol in there.
Title: Re: Draw "not standard" char
Post by: GabrielS on June 14, 2013, 07:33:56 pm
Ah perfect, I managed to use sf::String correctly !

Thanks for the responses.