in reply to Perl, Gtk2 and locale — a bit of a mess

I think I don’t understand anything anymore. Look:

~$ locale LANG=hu_HU.UTF-8 LC_CTYPE="hu_HU.UTF-8" LC_NUMERIC="hu_HU.UTF-8" LC_TIME="hu_HU.UTF-8" LC_COLLATE="hu_HU.UTF-8" LC_MONETARY="hu_HU.UTF-8" LC_MESSAGES="hu_HU.UTF-8" LC_PAPER="hu_HU.UTF-8" LC_NAME="hu_HU.UTF-8" LC_ADDRESS="hu_HU.UTF-8" LC_TELEPHONE="hu_HU.UTF-8" LC_MEASUREMENT="hu_HU.UTF-8" LC_IDENTIFICATION="hu_HU.UTF-8" LC_ALL= ~$ perl -e 'use POSIX qw(setlocale LC_ALL); print setlocale(LC_ALL);' +## Print the current locale LC_CTYPE=hu_HU.UTF-8;LC_NUMERIC=C;LC_TIME=hu_HU.UTF-8;LC_COLLATE=hu_HU +.UTF-8;LC_MONETARY=hu_HU.UTF-8;LC_MESSAGES=hu_HU.UTF-8;LC_PAPER=hu_HU +.UTF-8;LC_NAME=hu_HU.UTF-8;LC_ADDRESS=hu_HU.UTF-8;LC_TELEPHONE=hu_HU. +UTF-8;LC_MEASUREMENT=hu_HU.UTF-8;LC_IDENTIFICATION=hu_HU.UTF-8

Why is everything set except for LC_NUMERIC? Why is anything set? I never asked for this...

Update: C does the following:

#include <stdio.h> #include <locale.h> int main() { printf("%s\n", setlocale(LC_ALL, NULL)); setlocale(LC_ALL, ""); printf("%s\n", setlocale(LC_ALL, NULL)); return 0; }
~$ ./localetest C hu_HU.UTF-8

Replies are listed 'Best First'.
Re^2: Perl, Gtk2 and locale — a bit of a mess (POSIX)
by Anonymous Monk on Jul 15, 2013 at 09:54 UTC

    What does the POSIX standard say should happen? What does your system say setlocale should do?

    The setlocale link talks about  POSIX::setlocale( LC_ALL , "" ) setting stuff like you're seeing, but in perl its the default  Usage: POSIX::setlocale(category, locale = 0)

    To query you use NULL, perls equivalent is

    $ perl -e " use POSIX qw/ setlocale LC_ALL /; print setlocale( LC_ALL +, undef ); " English_United States.1252

    So I don't think I'm seeing a bug here, looks like its working as designed

      POSIX(3pm) says that the Perl equivalent of C’s setlocale(cat, NULL) is setlocale($cat) (i.e. one argument). I’m not explicitly setting the locale to the environment-given locale (setlocale($cat, "") or in C setlocale(cat, "")) until later in the code, so it should default to C locale.

      Also, setlocale(3) says the following: “If locale {the second param} is NULL, the current locale is only queried, not modified. On startup of the main program, the portable "C" locale is selected as default. A program may be made portable to all locales by calling setlocale(LC_ALL, "" ) after program initialization”