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

Author Topic: [SOLVED] Draw "not standard" char  (Read 1685 times)

0 Members and 1 Guest are viewing this topic.

GabrielS

  • Newbie
  • *
  • Posts: 25
    • View Profile
[SOLVED] Draw "not standard" char
« 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
« Last Edit: June 14, 2013, 07:34:27 pm by GabrielS »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Draw "not standard" char
« Reply #1 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.
« Last Edit: June 13, 2013, 10:23:45 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

GabrielS

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Draw "not standard" char
« Reply #2 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);

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Draw "not standard" char
« Reply #3 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.
Back to C++ gamedev with SFML in May 2023

GabrielS

  • Newbie
  • *
  • Posts: 25
    • View Profile
Re: Draw "not standard" char
« Reply #4 on: June 14, 2013, 07:33:56 pm »
Ah perfect, I managed to use sf::String correctly !

Thanks for the responses.

 

anything