From d779c743c1f340b7021d397cfd66f57d7d73bd11 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Thu, 12 Sep 2024 02:08:25 +0200 Subject: [PATCH] instead of just getting Latin1 we practically see getting 2 or 3 bytes (even for characters that representable in Latin1) so try our best to interpret them --- Source/x11/XIMInputServer.m | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/x11/XIMInputServer.m b/Source/x11/XIMInputServer.m index 690d807f..77bc594c 100644 --- a/Source/x11/XIMInputServer.m +++ b/Source/x11/XIMInputServer.m @@ -151,12 +151,18 @@ - (NSString *) lookupStringForEvent: (XKeyEvent *)event { /* Always returns a Latin-1 string according to the manpage */ count = XLookupString (event, buf, BUF_LEN, &keysym, NULL); - if (count) + if (count == 1) { keys = [[[NSString alloc] initWithBytes: buf length: count encoding: NSISOLatin1StringEncoding] autorelease]; } + else if (count > 1) // manpage lies and we suppose UTF-8 + { + keys = [[[NSString alloc] initWithBytes: buf + length: count + encoding: NSUTF8StringEncoding] autorelease]; + } if (keysymptr) *keysymptr = keysym;