On Sat, Mar 29, 2025, at 2:25 PM, Chet Ramey wrote:
> How does a locale doing this expose the category to the programmer?
> I suppose all possible additional locale categories have to be available
> to setlocale() somehow, via <locale.h> and the documentation.
Yeah, looks like POSIX explicitly permits that:
The <locale.h> header shall define NULL (as described in
<stddef.h>) and at least the following as macros:
LC_ALL
LC_COLLATE
LC_CTYPE
[CX] [Option Start]
LC_MESSAGES
[Option End]
LC_MONETARY
LC_NUMERIC
LC_TIME
which shall expand to integer constant expressions with
distinct values for use as the first argument to the
setlocale() function.
Additional macro definitions, beginning with the characters
LC_ and an uppercase letter, may also be specified by the
implementation.
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/basedefs/locale.h.html
> Does anyone have an example of a locale that defines additional categories?
glibc defines several and seems to use them in many (all?) of its
locale definitions.
https://man7.org/linux/man-pages/man7/locale.7.html
https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/locale.h;hb=glibc-2.41#l33
https://sourceware.org/git/?p=glibc.git;a=blob;f=locale/langinfo.h;hb=glibc-2.41#l584
https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/locales/en_US;hb=glibc-2.41
--
vq