From: Godmar Back <godmar@gmail.com>
To: William Tambe via Libc-help <libc-help@sourceware.org>
Subject: why does `LANG` not influence the locale in GNU/Linux
Date: Wed, 26 Jan 2022 19:35:41 -0500 [thread overview]
Message-ID: <CAB4+JYLdJbJfp4CdfxQV4BrxTcHN_0mhtE+Ae-+hOD+Qt44Z-w@mail.gmail.com> (raw)
If I am writing code that uses fgetwc to read from standard input, I
need to call setlocale(LC_CTYPE, "en_US.utf8"); to ensure that fgetwc
will treat stdin as a UTF-8 encoded stream. This property appears to
hold (on Ubuntu 20, with default GNU libc), independent of the setting
of LANG. LANG is set to en_US.utf8.
By contrast, Python 3 changes its behavior with regard to the encoding
it assumes sys.stdin to be in based on the LANG variable - if set to
en_US.utf8, it'll decode as UTF-8, if set to C or unset, it'll treat
the input as 8-bit ASCII encoding (I believe).
My question is why GNU libc (chose?) to not use LANG and what
standards, if any, apply here.
Is my characterization of the behavior correct?
- Godmar
next reply other threads:[~2022-01-27 0:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 0:35 Godmar Back [this message]
2022-01-27 5:28 ` Carlos O'Donell
2022-01-27 5:40 ` Godmar Back
2022-01-27 5:53 ` Carlos O'Donell
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=CAB4+JYLdJbJfp4CdfxQV4BrxTcHN_0mhtE+Ae-+hOD+Qt44Z-w@mail.gmail.com \
--to=godmar@gmail.com \
--cc=libc-help@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).