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

Author Topic: Unicode encoding  (Read 1121 times)

0 Members and 1 Guest are viewing this topic.

Septimium

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Unicode encoding
« on: May 05, 2014, 03:35:25 am »
Hello, (sorry for my poor english)

I have a "problem" while trying to get a character from my keyboard, I use this:
Quote
event.text.unicode
to retreive it, but after that I don't know how to convert it into ascii.

I searched and saw some methods to do it, but no one work for me.

I tried a lot of things, like simply cast it into a char or pass by a sf::string ... etc, and nothing worked.


Characters typed on my keyboard are stocked into a std::string, and then I just want to display this string by a sf::text

Quote
std::string s = "";

//event keypressed
s += event.text.unicode;

//In my rendering thread
sf::Text text;
text.setString(s);
window->draw(text);

Could someone give me the missing line to convert my unicode string into a displayable string ?

Thank you :) (and again, sorry for my english)

G.

  • Hero Member
  • *****
  • Posts: 1593
    • View Profile
Re: Unicode encoding
« Reply #1 on: May 05, 2014, 04:14:30 am »
event.text.unicode is not defined inside sf::Event::KeyPressed, but inside sf::Event::TextEntered
http://www.sfml-dev.org/tutorials/2.1/window-events.php#the-textentered-event

Septimium

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Re: Unicode encoding
« Reply #2 on: May 05, 2014, 05:18:17 am »
Well . . . i fell into the trap, thank you it's now working.

 

anything