Bug 86148 - XLookupString() returns UTF-8 instead of Latin-1
Summary: XLookupString() returns UTF-8 instead of Latin-1
Status: RESOLVED MOVED
Alias: None
Product: xorg
Classification: Unclassified
Component: Lib/Xlib (show other bugs)
Version: 7.7 (2012.06)
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Xorg Project Team
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-11 13:01 UTC by Christian Bauer
Modified: 2018-08-10 20:10 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Bauer 2014-11-11 13:01:00 UTC
In a UTF-8 locale, the string stored by XLookupString() in the buffer_return argument uses UTF-8 encoding (for this test I switched to a German keyboard layout using the Gnome keyboard layout selector and hit the 'Ä' key):

$ locale
LANG=en_US.utf8
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=
$ xev
[...]
KeyPress event, serial 42, synthetic NO, window 0x1e00001,
    root 0xa2, subw 0x1e00002, time 95582723, (32,24), root:(1952,532),
    state 0x0, keycode 48 (keysym 0xe4, adiaeresis), same_screen YES,
    XLookupString gives 2 bytes: (c3 a4) "ä"
    XmbLookupString gives 2 bytes: (c3 a4) "ä"
    XFilterEvent returns: False
[...]

According to the manpage, however, XLookupString() is supposed to always use ISO Latin-1 encoding so it should return 1 byte (e4).

The present behavior of XLookupString() breaks legacy applications which expect this function to return a Latin-1 encoded string.

Additional version information:

$ cat /etc/fedora-release 
Fedora release 20 (Heisenbug)
$ rpm -q libX11
libX11-1.6.1-1.fc20.x86_64
$ X -version

X.Org X Server 1.14.4
Release Date: 2013-10-31
X Protocol Version 11, Revision 0
Build Operating System:  3.14.3-200.fc20.x86_64 
Current Operating System: Linux pengolod.intern 3.16.7-200.fc20.x86_64 #1 SMP Thu Oct 30 18:12:41 UTC 2014 x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-3.16.7-200.fc20.x86_64 root=UUID=e10befbd-0183-439f-a502-4b689761f29d ro vconsole.font=latarcyrheb-sun16 rhgb quiet LANG=en_US.utf8
Build Date: 27 June 2014  01:35:28AM
Build ID: xorg-x11-server 1.14.4-11.fc20 
Current version of pixman: 0.30.0
Comment 1 GitLab Migration User 2018-08-10 20:10:53 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/39.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.