nl_langinfo() — Retrieve Locale Information
Format
#include <langinfo.h>
#include <nl_types.h>
char *nl_langinfo(nl_item item);
Language Level
XPG4
Threadsafe
No
Locale Sensitive
The behavior of this function might be affected by the LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, and LC_TIME categories of the current locale. This function is not available when LOCALETYPE(*CLD) is specified on the compilation command. For more information, see Understanding CCSIDs and Locales.
Description
The nl_langinfo()
function
retrieves from the current locale the string that describes the requested
information specified by item.
The retrieval of the following information from the current locale is supported:
Item | Explanation |
---|---|
CODESET | CCSID of locale in character form |
D_T_FMT | string for formatting date and time |
D_FMT | date format string |
T_FMT | time format string |
T_FMT_AMPM | a.m. or p.m. time format string |
AM_STR | Ante Meridian affix |
PM_STR | Post Meridian affix |
DAY_1 | name of the first day of the week (for example, Sunday) |
DAY_2 | name of the second day of the week (for example, Monday) |
DAY_3 | name of the third day of the week (for example, Tuesday) |
DAY_4 | name of the fourth day of the week (for example, Wednesday) |
DAY_5 | name of the fifth day of the week (for example, Thursday) |
DAY_6 | name of the sixth day of the week (for example, Friday) |
DAY_7 | name of the seventh day of the week (for example, Saturday) |
ABDAY_1 | abbreviated name of the first day of the week |
ABDAY_2 | abbreviated name of the second day of the week |
ABDAY_3 | abbreviated name of the third day of the week |
ABDAY_4 | abbreviated name of the fourth day of the week |
ABDAY_5 | abbreviated name of the fifth day of the week |
ABDAY_6 | abbreviated name of the sixth day of the week |
ABDAY_7 | abbreviated name of the seventh day of the week |
MON_1 | name of the first month of the year |
MON_2 | name of the second month of the year |
MON_3 | name of the third month of the year |
MON_4 | name of the fourth month of the year |
MON_5 | name of the fifth month of the year |
MON_6 | name of the sixth month of the year |
MON_7 | name of the seventh month of the year |
MON_8 | name of the eighth month of the year |
MON_9 | name of the ninth month of the year |
MON_10 | name of the tenth month of the year |
MON_11 | name of the eleventh month of the year |
MON_12 | name of the twelfth month of the year |
ABMON_1 | abbreviated name of the first month of the year |
ABMON_2 | abbreviated name of the second month of the year |
ABMON_3 | abbreviated name of the third month of the year |
ABMON_4 | abbreviated name of the fourth month of the year |
ABMON_5 | abbreviated name of the fifth month of the year |
ABMON_6 | abbreviated name of the sixth month of the year |
ABMON_7 | abbreviated name of the seventh month of the year |
ABMON_8 | abbreviated name of the eighth month of the year |
ABMON_9 | abbreviated name of the ninth month of the year |
ABMON_10 | abbreviated name of the tenth month of the year |
ABMON_11 | abbreviated name of the eleventh month of the year |
ABMON_12 | abbreviated name of the twelfth month of the year |
ERA | era description segments |
ERA_D_FMT | era date format string |
ERA_D_T_FMT | era date and time format string |
ERA_T_FMT | era time format string |
ALT_DIGITS | alternative symbols for digits |
RADIXCHAR | radix character |
THOUSEP | separator for thousands |
YESEXPR | affirmative response expression |
NOEXPR | negative response expression |
YESSTR | affirmative response for yes/no queries |
NOSTR | negative response for yes/no queries |
CRNCYSTR | currency symbol, preceded by '-' if the symbol should appear before the value, '+' if the symbol should appear after the value, or '.' if the symbol should replace the radix character |
Returned Value
The nl_langinfo()
function
returns a pointer to a null-ended string containing information concerning
the active language or cultural area. The active language or cultural
area is determined by the most recent setlocale()
call.
The array pointed to by the returned value is modified by subsequent
calls to the function. The array should not be changed by the user's
program.
If the item is not valid, the function returns a pointer to an empty string.
Example
nl_langinfo()
function.
#include <langinfo.h>
#include <locale.h>
#include <nl_types.h>
#include <stdio.h>
int main(void)
{
printf("Current codeset is %s\n", nl_langinfo(CODESET));
return 0;
}
/************************************************************************
The output should be similar to:
Current codeset is 37
************************************************************************/