From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11879 invoked by alias); 12 Jun 2014 17:48:58 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 11865 invoked by uid 89); 12 Jun 2014 17:48:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout21.012.net.il Received: from mtaout21.012.net.il (HELO mtaout21.012.net.il) (80.179.55.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jun 2014 17:48:56 +0000 Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0N7200D00H2B7I00@a-mtaout21.012.net.il> for gdb-patches@sourceware.org; Thu, 12 Jun 2014 20:48:53 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0N7200DXNHHH7U00@a-mtaout21.012.net.il>; Thu, 12 Jun 2014 20:48:53 +0300 (IDT) Date: Thu, 12 Jun 2014 17:48:00 -0000 From: Eli Zaretskii Subject: Re: [ping] [PATCH] Different outputs affected by locale In-reply-to: <5399E216.1090601@redhat.com> To: Pedro Alves Cc: yao@codesourcery.com, tromey@redhat.com, brobecker@adacore.com, gdb-patches@sourceware.org Reply-to: Eli Zaretskii Message-id: <83k38mxbm0.fsf@gnu.org> References: <1401192650-29688-1-git-send-email-yao@codesourcery.com> <538EAEE5.2080708@codesourcery.com> <20140604124708.GR4289@adacore.com> <538F1CC3.9090605@codesourcery.com> <87oay8a0t6.fsf@fleche.redhat.com> <538F803A.9020007@redhat.com> <538FE412.1050806@codesourcery.com> <53903119.6000204@redhat.com> <53903EE5.8090107@codesourcery.com> <539042A2.4050409@redhat.com> <539571C6.40605@codesourcery.com> <53958862.5020106@redhat.com> <5397BCEC.8080300@codesourcery.com> <539990BD.9020504@redhat.com> <5399BB32.5050409@codesourcery.com> <5399E216.1090601@redhat.com> X-IsSubscribed: yes X-SW-Source: 2014-06/txt/msg00516.txt.bz2 > Date: Thu, 12 Jun 2014 18:23:34 +0100 > From: Pedro Alves > CC: Tom Tromey , Joel Brobecker , gdb-patches@sourceware.org > > On 06/12/2014 03:37 PM, Yao Qi wrote: > > On 06/12/2014 07:36 PM, Pedro Alves wrote: > >> What does "show host-charset" show on Windows, before and after > >> you make GDB pick LC_CTYPE=C from the environment (with the > >> setlocale gnulib module)? > > > > GDB on Windows gets host charset from GetACP(), in > > charset.c:_initialize_charset (). > > > > #elif defined (USE_WIN32API) > > { > > /* "CP" + x<=5 digits + paranoia. */ > > static char w32_host_default_charset[16]; > > > > snprintf (w32_host_default_charset, sizeof w32_host_default_charset, > > "CP%d", GetACP()); > > auto_host_charset_name = w32_host_default_charset; > > auto_target_charset_name = auto_host_charset_name; > > } > > #endif > > > > I note gnulib's nl_langinfo replacement actually does > the same thing. And gnulib's nl_langinfo is wrong, btw, because one can use 'setlocale' to change the codeset, without any relation whatsoever to the console encoding. (I sent a fix for that to gnulib's list just yesterdat.) > > GetACP doesn't depend on locale, > > Yeah, it's a mess, and those are really different > things. The former is the system locale, while the latter > the user locale. That's true, but that's not the important issue here. The important issue here is the fundamental difference between the Windows console encoding and the current locale's codeset. The former affects how Windows writes to the console, and in most cases changing the console codepage (e.g., with SetConsoleCP or SetConsoleOutputCP) is a futile exercise, because all it does is cause garbled display. The latter is an important feature when you are dealing with programs that don't intend using the codeset to display text to the user, but, for example, to change the behavior of iswprint. Using the console codepage when really the locale's codeset is needed will only going to work for the default setup, not when you want or need to change the locale.