Search code examples
clocale

What do the mask bits for newlocale(3) mean, specifically?


The man page for newlocale(3) says in part:

The mask is the logical OR of the following:

LC_COLLATE_MASK   Collation  
LC_CTYPE_MASK     Character type  
LC_MESSAGES_MASK  Messages
LC_MONETARY_MASK  Monetary
LC_NUMERIC_MASK   Numeric
LC_TIME_MASK      Time
LC_ALL_MASK       The logical OR of all of the above

but it doesn't say what each of the mask bits actually means specifically. In my case, I need the localized strings for AM_STR, PM_STR, month abbreviations (ABMON_1, ...), full month names (MON_1, ...), weekday abbreviations (ABDAY_1, ...), and full weekday names (DAY_1, ...).

As an educated guess, I think I need LC_MESSAGES_MASK -- but do I also need LC_TIME_MASK?


Solution

  • You need LC_TIME_MASK; you don't need LC_MESSAGES_MASK for your stated requirements.

    LC_MESSAGES controls error messages, not time formatting. To see what the 'unmasked' names such as LC_TIME mean, consult the man page for setlocale(3). They are standard C (though the POSIX page linked to includes some extensions — notably the "POSIX" locale).