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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Rastislav Kiss

Pages: [1]
1
General / Utf-8 coding problem
« on: February 02, 2018, 08:13:44 pm »
Hi all,
I am Rastislav Kiss, new on this forum. I would like to ask an question about problem I have encountered in SFML.
I am trying to create a simple app, which will show the window and catch all pressed keys as the characters to collect user input.
Window is fine, but the writing part is a problem. My code for events catching looks as follows:

      while (window.pollEvent(event))
         {
         if (event.type==sf::Event::TextEntered)
            {
            textbuffer+=event.text.unicode;
            }
         }

where textbuffer is an SF::String. I have also one method, which retrieves currently typed text

std::string get_characters()
   {
   std::string output=textbuffer.toAnsiString();
   textbuffer="";
   return output;
   }

It works, until I type some special characters of the Slovak language. If I do so, after some tests I found out, that key is catched and represented properly, but conversion to ascii fails. Characters like š, č or ť are not present in result string, although for example ý is represented correctly.
It is a bug in SFML, or just I'm doing something wrong? If yes, can you please tell me, how to do it correctly?

Thank you in advance.

Best regards

Rastislav

Pages: [1]
anything