SDL_TEXTINPUT event: I don't receive accents

Hi everyone :).
I’m moving my game from SDL 1.2 to SDL 2.0.
In SDL 1.2, I used the SDL_EnableUNICODE() function in order to receive input text from users. So I tried the new SDL_TEXTINPUT event :

Code:
case SDL_TEXTINPUT:
message.insert(cursor,event.text.text);
cursor=(int)(message.length());
break;

It works well for every character like “a-z0-9” etc…
But here’s the problem: I am French and we have different kind of characters like ???. When I type on of them, it does receive something but it’s different than the character I typed. For instance, when I type ? I receive “??”. I think it’s an encoding problem, but how can I fix it ? I’ve been trying several things but it doesn’t seem to change anything …
When I used UNICODE in SDL 1.2 it worked fine though.

Thank you.
Have a good day :)[/code]

I’m not sure that’s SDL’s fault at all.

If I recall correctly SDL works exclusively with UTF-8, and in fact
that looks like the kind of encoding error I’d expect from UTF-8 being
parsed as something else. Are you sure the problem is not elsewhere?

2013/11/20, Grade :> Hi everyone :).

I’m moving my game from SDL 1.2 to SDL 2.0.
In SDL 1.2, I used the SDL_EnableUNICODE() function in order to receive
input text from users. So I tried the new SDL_TEXTINPUT event :

Code:
case SDL_TEXTINPUT:
message.insert(cursor,event.text.text);
cursor=(int)(message.length());
break;

It works well for every character like “a-z0-9” etc…
But here’s the problem: I am French and we have different kind of characters
like ???. When I type on of them, it does receive something but it’s
different than the character I typed. For instance, when I type ? I receive
"??". I think it’s an encoding problem, but how can I fix it ? I’ve been
trying several things but it doesn’t seem to change anything …
When I used UNICODE in SDL 1.2 it worked fine though.

Thank you.
Have a good day :)[/code]

Presuming that you are using std::string, try using std::wstring; from
there, you’ll have to convert from a wide string to a UTF-8 compatible one
(like std::string) - check out this stackoverflow
threadhttp://stackoverflow.com/questions/4804298/how-to-convert-wstring-into-stringfor
details on that process.On Wed, Nov 20, 2013 at 11:42 AM, Grade wrote:

Hi everyone [image: Smile].
I’m moving my game from SDL 1.2 to SDL 2.0.
In SDL 1.2, I used the SDL_EnableUNICODE() function in order to receive
input text from users. So I tried the new SDL_TEXTINPUT event :

Code:

case SDL_TEXTINPUT:
message.insert(cursor,event.text.text);
cursor=(int)(message.length());
break;

It works well for every character like “a-z0-9” etc…
But here’s the problem: I am French and we have different kind of
characters like ???. When I type on of them, it does receive
something but it’s different than the character I typed. For instance, when
I type ? I receive “??”. I think it’s an encoding problem, but how can I
fix it ? I’ve been trying several things but it doesn’t seem to change
anything …
When I used UNICODE in SDL 1.2 it worked fine though.

Thank you.
Have a good day [image: Smile][/code]


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org