[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: strange behaviour with accented chars on debian unstable
- From: Dave Dodge <dododge@...>
- Date: Mon, 7 Nov 2005 20:06:16 -0500
On Fri, Nov 04, 2005 at 11:31:40AM -0300, Walter Cruz wrote:
> Look out: I've made a little script to print all the locale environment.
>
> ----getenv.lua--------
>
> print(os.getenv("LANG"))
...
> print(os.getenv("LC_MEASUREMENT"))
> print(os.getenv("LC_IDENTIFICATION"))
> print(os.getenv("LC_ALL"))
>
> -------getenv.lua ---------
>
> and now:
>
> MCid299a:~/lua$ locale
> LANG=pt_BR
...
> LC_MEASUREMENT="pt_BR"
> LC_IDENTIFICATION="pt_BR"
> LC_ALL=
>
> MCid299a:~/lua$ lua getenv.lua
> pt_BR
...
> nil
> nil
> nil
I believe this is normal. The "LC_*" values that "locale" is
reporting are the locale categories themselves (as reported by
setlocale()), not environment variables. Environment variables can be
used to influence the category values, but this is optional.
For example when a program is determining the initial value for the
LC_MEASUREMENT category, it will first look for an LC_MEASUREMENT
environment variable. If none is set, it tries the LC_ALL environment
variable as a default. If that isn't set, it looks for LANG as a
further default. If all of your categories are the same, the LANG
environment variable is sufficient to initialize them.
For details, See section 8.2 of the POSIX/UNIX specification:
http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
Note that this behavior is POSIX-specific. Standard C doesn't specify
any relationship between environment variables and the locale, so
portable scripts shouldn't rely on those variables.
-Dave Dodge