public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* why does `LANG` not influence the locale in GNU/Linux
@ 2022-01-27  0:35 Godmar Back
  2022-01-27  5:28 ` Carlos O'Donell
  0 siblings, 1 reply; 4+ messages in thread
From: Godmar Back @ 2022-01-27  0:35 UTC (permalink / raw)
  To: William Tambe via Libc-help

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-27  5:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-27  0:35 why does `LANG` not influence the locale in GNU/Linux Godmar Back
2022-01-27  5:28 ` Carlos O'Donell
2022-01-27  5:40   ` Godmar Back
2022-01-27  5:53     ` Carlos O'Donell

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).