unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: libc-alpha@sourceware.org
Cc: Bruno Haible <bruno@clisp.org>
Subject: [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621)
Date: Tue, 15 Nov 2022 01:56:23 +0100	[thread overview]
Message-ID: <20221115005623.3774099-1-bruno@clisp.org> (raw)

The wiki page https://sourceware.org/glibc/wiki/Proposals/C.UTF-8
says that "Setting LC_ALL=C.UTF-8 will ignore LANGUAGE just like it
does with LC_ALL=C." This patch implements it.

* intl/dcigettext.c (guess_category_value): Treat C.<encoding> locale
like the C locale.
---
 intl/dcigettext.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/intl/dcigettext.c b/intl/dcigettext.c
index 1fc074a414..6a3c248e68 100644
--- a/intl/dcigettext.c
+++ b/intl/dcigettext.c
@@ -1564,8 +1564,12 @@ guess_category_value (int category, const char *categoryname)
      2. The precise output of some programs in the "C" locale is specified
 	by POSIX and should not depend on environment variables like
 	"LANGUAGE" or system-dependent information.  We allow such programs
-        to use gettext().  */
-  if (strcmp (locale, "C") == 0)
+        to use gettext().
+     Ignore LANGUAGE and its system-dependent analogon also if the locale is
+     set to "C.UTF-8" or, more generally, to "C.<encoding>", because that's
+     the by-design behaviour for glibc, see
+     <https://sourceware.org/glibc/wiki/Proposals/C.UTF-8>.  */
+  if (locale[0] == 'C' && (locale[1] == '\0' || locale[1] == '.'))
     return locale;
 
   /* The highest priority value is the value of the 'LANGUAGE' environment
-- 
2.34.1


             reply	other threads:[~2022-11-15  0:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15  0:56 Bruno Haible [this message]
2023-09-04 13:34 ` [PATCH] intl: Treat C.UTF-8 locale like C locale (BZ# 16621) Florian Weimer via Libc-alpha
2023-09-10 19:10   ` Bruno Haible
  -- strict thread matches above, loose matches on Subject: below --
2023-11-20 18:12 Bruno Haible

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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221115005623.3774099-1-bruno@clisp.org \
    --to=bruno@clisp.org \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).