Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose key with TextInput returns double utf8 encoded string #1956

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 0 comments
Closed

Compose key with TextInput returns double utf8 encoded string #1956

SDLBugzilla opened this issue Feb 11, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

Reported in version: HG 2.1
Reported for operating system, platform: Linux, x86_64

Comments on the original bug report:

On 2015-08-25 00:24:07 +0000, Dennis Felsing wrote:

I'm on Linux, X server 1.17.2 and trying to enter a smiley (☺) in an SDL2 program.

With a compose key this works fine in xev:

KeyPress event, serial 32, synthetic NO, window 0xe00001,
root 0x4a1, subw 0x0, time 14483802, (479,264), root:(1440,283),
state 0x1, keycode 0 (keysym 0x100263a, U263A), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 3 bytes: (e2 98 ba) "☺"
XFilterEvent returns: False

With SDL2' checkkeys I get a wrong output instead:

INFO: INPUT Text (\xc3\xa2\xc2\x98\xc2\xba): "âº"

After looking at it closely, I noticed that the SDL2 string utf8 encodes each utf8 encoded byte. Instead it should just be utf8 encoded once of course.

Is there any way to fix this or work around it? I haven't noticed this problem in anything other than SDL2 programs. SDL1.2 worked fine.

On 2015-09-29 18:12:34 +0000, Alex Baines wrote:

If you add a call to setlocale(LC_ALL, "") at the start of checkkeys.c (and include locale.h in it) is this problem still present?

For me, checkkeys does not work with my compose key at all unless I add a setlocale call, and once I do that I get properly encoded strings.

On 2015-09-29 18:19:12 +0000, Dennis Felsing wrote:

Yes, that works, thanks a lot! So is it recommended to simply use setlocale(LC_ALL, "") at the start of my program or is this something that can be fixed in SDL?

On 2015-09-29 18:42:05 +0000, Alex Baines wrote:

SDL1.2 used to call setlocale internally before calling XOpenIM, but this was changed for some reason in SDL2.

It could be changed back, but this might have been done to fix some other bug, I'm not sure.

It's probably best to call it yourself for the moment.

On 2016-10-01 21:10:31 +0000, Sam Lantinga wrote:

Fixed by Alex's patch in bug 3136
https://hg.libsdl.org/SDL/rev/2f18ea79bc03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant