From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PULL 10/10] gtk: Hardcode LC_CTYPE as C.utf-8
Date: Tue, 31 Jan 2017 14:41:46 +0100 [thread overview]
Message-ID: <1485870106-25016-11-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1485870106-25016-1-git-send-email-kraxel@redhat.com>
From: Kevin Wolf <kwolf@redhat.com>
Commit 2cb5d2a4 removed setlocale() for everything except LC_MESSAGES in
order to avoid unwanted side effects such as using the wrong decimal
separator in generated JSON objects. However, the problem that unsetting
LC_CTYPE caused is that non-ASCII characters are considered
non-printable now and therefore the GTK menus display question marks for
accented letters, Chinese characters etc.
A first attempt to fix this [1] was rejected because even just setting
LC_CTYPE to the user's locale (and thereby modifying the semantics of
the ctype.h functions) could have unwanted effects that we're not aware
of yet.
Recently, however, glibc introduced a new locale "C.utf-8" that just
uses UTF-8 as its charset, but otherwise leaves the semantics alone.
Just setting the right character set is enough for our use case, so we
can just hardcode this one without having to be afraid of nasty side
effects.
Older systems that don't have the new locale will continue displaying
question marks, but this should fix the problem for most users.
[1] https://lists.gnu.org/archive/html/qemu-devel/2015-12/msg03591.html
('Re: gtk: use setlocale() for LC_MESSAGES only')
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20170131100945.8189-1-kwolf@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/gtk.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index b734c0b..3c415d2 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2258,8 +2258,12 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
s->free_scale = FALSE;
- /* LC_MESSAGES only. See early_gtk_display_init() for details */
+ /* Mostly LC_MESSAGES only. See early_gtk_display_init() for details. For
+ * LC_CTYPE, we need to make sure that non-ASCII characters are considered
+ * printable, but without changing any of the character classes to make
+ * sure that we don't accidentally break implicit assumptions. */
setlocale(LC_MESSAGES, "");
+ setlocale(LC_CTYPE, "C.utf-8");
bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
textdomain("qemu");
--
1.8.3.1
next prev parent reply other threads:[~2017-01-31 13:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 13:41 [Qemu-devel] [PULL 00/10] ui patch queue Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 01/10] qapi: add support for mice with extra/side buttons Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 02/10] ps2: " Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 03/10] ui: " Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 04/10] vnc: track LED state separately Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 05/10] ui/gtk: Fix mouse wheel on 3.4.0 or later Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 06/10] ui: fix format specfier in vnc to avoid break in build Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 07/10] ui/gtk.c: add ctrl-alt-= support for zoom in acceleration Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 08/10] spice: wakeup QXL worker to pick up mouse changes Gerd Hoffmann
2017-01-31 13:41 ` [Qemu-devel] [PULL 09/10] vnc: fix overflow in vnc_update_stats Gerd Hoffmann
2017-01-31 13:41 ` Gerd Hoffmann [this message]
2017-01-31 14:00 ` [Qemu-devel] [PULL 00/10] ui patch queue Eric Blake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1485870106-25016-11-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).