Patrice Dumas wrote:
> I had a look at the setlocale man page on this platform and there is
> this paragraph:
>
> On OpenBSD, the only useful value for the category is LC_CTYPE. It sets
> the locale used for character encoding, character classification, and
> case conversion. For compatibility with natural language support in
> packages(7), all other categories -- LC_COLLATE, LC_MESSAGES,
> LC_MONETARY, LC_NUMERIC, and LC_TIME -- can be set and retrieved, too,
> but their values are ignored by the OpenBSD C library. A category of
> LC_ALL sets the entire locale generically, which is strongly discouraged
> for security reasons in portable programs.
>
> So, unless I misinterpret this, it seems that LC_CTYPE should be used
> instead of LC_MESSAGES on that platform.
No, no. You can't take the OpenBSD man page regarding locales seriously
because the OpenBSD people haven't understood locales:
* They think that because in different locales, some results are different,
locales are dangerous and need to be discouraged.
* While they have a setlocale() that remembers the given value — for the
packages, as they say, — they have forgotten to implement the same thing
in uselocale(). Making uselocale() pointless in OpenBSD.
* setlocale (LC_ALL, value) is equivalent to
setlocale (LC_CTYPE, value)
&& setlocale (LC_MESSAGES, value)
&& setlocale (LC_NUMERIC, value)
&& ...
When you set only LC_CTYPE, messages will always come out untranslated,
i.e. in English.
> setenv_status = setenv ("LC_ALL", "en_US.UTF-8", 1)
> || setenv ("LANG", "en_US.UTF-8", 1);
> locale = setlocale (LC_MESSAGES, "");
The second of these lines is redundant: If setenv ("LC_ALL", "en_US.UTF-8", 1)
fails, the only possible reason is out-of-memory, and then it's pointless to
try the same thing with "LANG".
Bruno