[luatex] luatex with unexpected locale
luigi scarso
luigi.scarso at gmail.com
Fri Aug 18 05:42:55 CEST 2017
On Fri, Aug 18, 2017 at 2:22 AM, Norbert Preining <preining at logic.at> wrote:
> Hi Luigi,
>
>> luatex exits if setlocale (LC_ALL, "") returns NULL,
>
> Indeed, that is what has happened in our case.
>From the manual
"""
If locale is an empty string, "", each part of the locale that
should be modified is set according to the environment variables. The
details are implementation-dependent. For glibc, first (regardless of
category), the environment variable LC_ALL is
inspected, next the environment variable with the same name as
the category (see the table above), and finally the environment
variable LANG. The first existing environment variable is used. If
its value is not a valid locale specification, the locale is
unchanged, and setlocale() returns NULL.
"""
If the locale from the environment is not a valid locale,
I cannot set the values of
lc_ctype, lc_collate, lc_numeric
ie the values from the environment.
>
> Perl treats this with a warning and say: resetting to C,
I know, luatex --luaonly does the same, but
luatex is different from luatex --luaonly .
>> of course we could force the locale to C, so that lc_type, lc_collate
>> and lc_numeric always store "C" (pretty useless) but this can also
>
> Why? You *are* doing that anyway! So what is about "pretty useles"?>
No, read the code, I don't set them:
putenv(LC_CTYPE_C);
putenv(LC_COLLATE_C);
putenv(LC_NUMERIC_C);
set the values of the env. variables to "C", but
I don't touch the values of lc_type, lc_collate lc_numeric,
which are the old values from the environment
(in previous versions there was no easy way to have their values on
the luatex side).
> Where are the locales used?
The user can use it, as shown in the example.
To recap:
nothing prevent , in case of an invalid locale,
to set lc_type, lc_collate and lc_numeric to NULL
or "C" or "" --- it doesn't matter, they are all wrong --- and go on
(of course we can emit a warning, that nobody cares).
But having a valid locale means that at least date and numbers
are formatted in a predictable way, which is quite important for a pdf document;
at least setting a locale to "C" or "POSIX" should work , but it is
the user's responsibility to
make the right choice.
--
luigi
More information about the luatex
mailing list