From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTvO6-0001FK-2i for qemu-devel@nongnu.org; Mon, 24 Aug 2015 13:18:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTvO2-0002xi-S6 for qemu-devel@nongnu.org; Mon, 24 Aug 2015 13:18:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49657) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTvO2-0002xK-NS for qemu-devel@nongnu.org; Mon, 24 Aug 2015 13:18:22 -0400 References: <20150818235754.GA31625@igalia.com> <87r3mtq9wx.fsf@blackfin.pond.sub.org> <87oahwr4x1.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <55DB51DC.6070704@redhat.com> Date: Mon, 24 Aug 2015 11:18:20 -0600 MIME-Version: 1.0 In-Reply-To: <87oahwr4x1.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4drVbTI29HNtrB7rEk8QUlKBPu7pjDvcx" Subject: Re: [Qemu-devel] QEMU produces invalid JSON due to locale-dependent code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Alberto Garcia Cc: qemu-devel@nongnu.org, Gerd Hoffmann This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4drVbTI29HNtrB7rEk8QUlKBPu7pjDvcx Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/24/2015 11:07 AM, Markus Armbruster wrote: >> You can prevent GTK+ from calling setlocale() by using >> gtk_disable_setlocale() before gtk_init(), but note that setlocale() i= s >> needed for gettext. >=20 > We can >=20 > (A) Internationalize our complete code base >=20 > (B) Run in the C locale >=20 > Breaks GTK's internationalization. >=20 > (C) Run in a mixed locale >=20 > Whenever something breaks, we switch another LC_ to the C locale. >=20 > Can partially break GTK's internationalization. >=20 > I happily concede that (A) would be best. Until the manpower to pull i= t > 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. Is it still possible for: (D) Run in a controlled mixed locale GTK runs completely in the locale determined by setlocale() (since it never has to display raw JSON) We fix our JSON output code to use thread-specific locale manipulations to (temporarily) switch to C locale before printing JSON that way, GTK still shows full German formatting for any localized message in the GUI that happens to print numbers, but the JSON output (which is independent of the GUI) also behaves correctly as a C-only enti= ty. I don't know how well mingw supports thread-specific locales (POSIX requires it, but we all know that mingw is behind the curve when it comes to POSIX...); BSD and glibc should be okay, though. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --4drVbTI29HNtrB7rEk8QUlKBPu7pjDvcx Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJV21HcAAoJEKeha0olJ0Nq9tEH/2ML6SgSVP8fX08PPN3J0tJN q8n+aRd58nKJ9NZvoHPCFGhPuslPUk2avAQ4q3AOTnbFfrusuvtlJEdYLZZ4ijpG RpD5M7ceIBXBgJm9muSqubn9eIXEvYeg3tBXBfJgGegjrjqFKPrFx/pfqRPq7HO3 CsyKIEge0fvigfSMgfRaP3eeDyHBOsr/m06gyvjcyH2IWtixJL/ef+DjUAR9KoiV tA5EiFKdjmz20dtrqzQdK0Bt1Pq6B5TN0pR5r61fNIkyZ1h/e+5Vwo+gCEg8t3DA qZDgrnAjXmwy8vYUTh4nAcBKss0PqG2z3wrh342phVx5O9LEEUEZmwJpTCYunyo= =FKVh -----END PGP SIGNATURE----- --4drVbTI29HNtrB7rEk8QUlKBPu7pjDvcx--