From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48187) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTvzL-0006XM-Qn for qemu-devel@nongnu.org; Mon, 24 Aug 2015 13:56:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTvzI-0007w9-5N for qemu-devel@nongnu.org; Mon, 24 Aug 2015 13:56:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTvzI-0007w5-0f for qemu-devel@nongnu.org; Mon, 24 Aug 2015 13:56:52 -0400 Date: Mon, 24 Aug 2015 18:56:48 +0100 From: "Daniel P. Berrange" Message-ID: <20150824175648.GV22295@redhat.com> References: <20150818235754.GA31625@igalia.com> <87r3mtq9wx.fsf@blackfin.pond.sub.org> <87oahwr4x1.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87oahwr4x1.fsf@blackfin.pond.sub.org> Subject: Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: Alberto Garcia , qemu-devel@nongnu.org, Gerd Hoffmann On Mon, Aug 24, 2015 at 07:07:38PM +0200, Markus Armbruster wrote: > Alberto Garcia writes: > > > On Mon 24 Aug 2015 12:05:02 PM CEST, Markus Armbruster wrote: > > > >>> This seems to happen because of GTK+ calling setlocale(). The easiest > >>> solution is probably to call setlocale(LC_NUMERIC, "C") before > >>> snprintf() (or at start-up ui/gtk.c), but opinions are welcome. > >> > >> A library calling setlocale() is a big no-no in my book. > >> > >> Overriding LC_NUMERIC as you propose should fix this particular bug. > >>However, exposing unprepared code to locale is not a good idea for > >>other categories as well. LC_COLLATE and LC_CTYPE are even sneakier > >>sources of bugs in my experience. I'd really, really prefer to stay in > >>the "C" locale *completely*. > > > > You can prevent GTK+ from calling setlocale() by using > > gtk_disable_setlocale() before gtk_init(), but note that setlocale() is > > needed for gettext. > > We can > > (A) Internationalize our complete code base > > (B) Run in the C locale > > Breaks GTK's internationalization. > > (C) Run in a mixed locale > > Whenever something breaks, we switch another LC_ to the C locale. > > Can partially break GTK's internationalization. > > I happily concede that (A) would be best. Until the manpower to pull it > off appears, I recommend (B), because it's safer than (C), and avoids > inconsistent localization, such as German messages combined with > non-German number formatting. It seems the only thing that we really care about being localized is the messages catalogue, so the GTK UI gets internationalization in its menus / dialogs / etc. As such I think that we should do the opposite of (C). ie run every LC_* in the C locale, except for LC_MESSAGES which we allow to be localized. This avoids any unpredictable functional consequences (like number formatting) while still giving user decent localization in the UI Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|