1 .\" $NetBSD: nl_langinfo.3,v 1.20 2011/04/14 05:50:49 jruoho Exp $
3 .\" Written by J.T. Conklin <jtc@NetBSD.org>.
11 .Nd get locale information
17 .Fn nl_langinfo "nl_item item"
21 function returns a pointer to a string containing information
22 set by the program's locale.
24 The names and values of
28 The entries under Category indicate in which
30 category each item is defined.
31 .Bl -column ERA_D_T_FMT LC_MESSAGES
32 .It Sy Constant Ta Sy Category Ta Sy Meaning
33 .It CODESET LC_CTYPE Codeset name
34 .It D_T_FMT LC_TIME String for formatting date and time
35 .It D_FMT LC_TIME Date format string
36 .It T_FMT LC_TIME Time format string
37 .It T_FMT_AMPM LC_TIME A.M. or P.M. time format string
38 .It AM_STR LC_TIME Ante-meridiem affix
39 .It PM_STR LC_TIME Post-meridiem affix
40 .It DAY_1 LC_TIME Name of the first day of the week (e.g.: Sunday)
41 .It DAY_2 LC_TIME Name of the second day of the week (e.g.: Monday)
42 .It DAY_3 LC_TIME Name of the third day of the week (e.g.: Tuesday)
43 .It DAY_4 LC_TIME Name of the fourth day of the week (e.g.: Wednesday)
44 .It DAY_5 LC_TIME Name of the fifth day of the week (e.g.: Thursday)
45 .It DAY_6 LC_TIME Name of the sixth day of the week (e.g.: Friday)
46 .It DAY_7 LC_TIME Name of the seventh day of the week (e.g.: Saturday)
47 .It ABDAY_1 LC_TIME Abbreviated name of the first day of the week
48 .It ABDAY_2 LC_TIME Abbreviated name of the second day of the week
49 .It ABDAY_3 LC_TIME Abbreviated name of the third day of the week
50 .It ABDAY_4 LC_TIME Abbreviated name of the fourth day of the week
51 .It ABDAY_5 LC_TIME Abbreviated name of the fifth day of the week
52 .It ABDAY_6 LC_TIME Abbreviated name of the sixth day of the week
53 .It ABDAY_7 LC_TIME Abbreviated name of the seventh day of the week
54 .It MON_1 LC_TIME Name of the first month of the year
55 .It MON_2 LC_TIME Name of the second month
56 .It MON_3 LC_TIME Name of the third month
57 .It MON_4 LC_TIME Name of the fourth month
58 .It MON_5 LC_TIME Name of the fifth month
59 .It MON_6 LC_TIME Name of the sixth month
60 .It MON_7 LC_TIME Name of the seventh month
61 .It MON_8 LC_TIME Name of the eighth month
62 .It MON_9 LC_TIME Name of the ninth month
63 .It MON_10 LC_TIME Name of the tenth month
64 .It MON_11 LC_TIME Name of the eleventh month
65 .It MON_12 LC_TIME Name of the twelfth month
66 .It ABMON_1 LC_TIME Abbreviated name of the first month
67 .It ABMON_2 LC_TIME Abbreviated name of the second month
68 .It ABMON_3 LC_TIME Abbreviated name of the third month
69 .It ABMON_4 LC_TIME Abbreviated name of the fourth month
70 .It ABMON_5 LC_TIME Abbreviated name of the fifth month
71 .It ABMON_6 LC_TIME Abbreviated name of the sixth month
72 .It ABMON_7 LC_TIME Abbreviated name of the seventh month
73 .It ABMON_8 LC_TIME Abbreviated name of the eighth month
74 .It ABMON_9 LC_TIME Abbreviated name of the ninth month
75 .It ABMON_10 LC_TIME Abbreviated name of the tenth month
76 .It ABMON_11 LC_TIME Abbreviated name of the eleventh month
77 .It ABMON_12 LC_TIME Abbreviated name of the twelfth month
78 .It ERA LC_TIME Era description segments
79 .It ERA_D_FMT LC_TIME Era date format string
80 .It ERA_D_T_FMT LC_TIME Era date and time format string
81 .It ERA_T_FMT LC_TIME Era time format string
82 .It ALT_DIGITS LC_TIME Alternative symbols for digits
83 .It RADIXCHAR LC_NUMERIC Radix character
84 .It THOUSEP LC_NUMERIC Separator for thousands
85 .It YESEXPR LC_MESSAGES Affirmative response expression
86 .It NOEXPR LC_MESSAGES Negative response expression
87 .\".It CRNCYSTR LC_MONETARY Local currency symbol
91 returns a pointer to an empty string if
95 The following example uses
97 to obtain the date and time format for the current locale:
99 .Bd -literal -offset indent
100 #include \*[Lt]time.h\*[Gt]
101 #include \*[Lt]langinfo.h\*[Gt]
102 #include \*[Lt]locale.h\*[Gt]
106 char datestring[100];
112 tm = localtime(\*[Am]t);
113 (void)setlocale(LC_ALL, "");
114 ptr = nl_langinfo(D_T_FMT);
115 strftime(datestring, sizeof(datestring), ptr, tm);
116 printf("%s\en", datestring);
121 .\" The following example uses
123 .\" to obtain the setting of the currency symbol for the current locale:
126 .\" #include \*[Lt]langinfo.h\*[Gt]
127 .\" #include \*[Lt]locale.h\*[Gt]
131 .\" (void)setlocale(LC_ALL, "");
132 .\" ptr = nl_langinfo(CRNCYSTR);
133 .\" printf("%s", ptr);