Add nsswitch support.
[dragonfly.git] / lib / libc / locale / nl_langinfo.3
1 .\"     $NetBSD: src/lib/libc/locale/nl_langinfo.3,v 1.13 2004/01/24 16:58:54 wiz Exp $
2 .\"     $DragonFly: src/lib/libc/locale/nl_langinfo.3,v 1.6 2008/05/02 02:05:04 swildner Exp $
3 .\"
4 .\" Written by J.T. Conklin <jtc@NetBSD.org>.
5 .\" Public domain.
6 .\"
7 .Dd February 12, 2003
8 .Dt NL_LANGINFO 3
9 .Os
10 .Sh NAME
11 .Nm nl_langinfo
12 .Nd get locale information
13 .Sh LIBRARY
14 .Lb libc
15 .Sh SYNOPSIS
16 .In langinfo.h
17 .Ft char *
18 .Fn nl_langinfo "nl_item item"
19 .Sh DESCRIPTION
20 The
21 .Fn nl_langinfo
22 function returns a pointer to a string containing information
23 set by the program's locale.
24 .Pp
25 The names and values of
26 .Fa item
27 are defined in
28 .In langinfo.h .
29 The entries under Category indicate in which
30 .Xr setlocale 3
31 category each item is defined.
32 .sp
33 .nf
34 .ta \w'ERA_D_T_FMT'u+1n +\w'LC_MESSAGES'u+1n +\w'Name of the third day of the week (e.g.: Tuesday)'u
35 \fIConstant\fP  \fICategory\fP  \fIMeaning\fP
36 .ta \w'ERA_D_T_FMT'u+1n +\w'LC_MESSAGES'u+1n +\w'Name of the third day of the week (e.g.: Tuesday)'u+1nC
37 .sp 5p
38 CODESET LC_CTYPE        Codeset name
39 D_T_FMT LC_TIME String for formatting date and time
40 D_FMT   LC_TIME Date format string
41 T_FMT   LC_TIME Time format string
42 T_FMT_AMPM      LC_TIME A.M. or P.M. time format string
43 AM_STR  LC_TIME Ante-meridiem affix
44 PM_STR  LC_TIME Post-meridiem affix
45 DAY_1   LC_TIME Name of the first day of the week (e.g.: Sunday)
46 DAY_2   LC_TIME Name of the second day of the week (e.g.: Monday)
47 DAY_3   LC_TIME Name of the third day of the week (e.g.: Tuesday)
48 DAY_4   LC_TIME Name of the fourth day of the week (e.g.: Wednesday)
49 DAY_5   LC_TIME Name of the fifth day of the week (e.g.: Thursday)
50 DAY_6   LC_TIME Name of the sixth day of the week (e.g.: Friday)
51 DAY_7   LC_TIME Name of the seventh day of the week (e.g.: Saturday)
52 ABDAY_1 LC_TIME Abbreviated name of the first day of the week
53 ABDAY_2 LC_TIME Abbreviated name of the second day of the week
54 ABDAY_3 LC_TIME Abbreviated name of the third day of the week
55 ABDAY_4 LC_TIME Abbreviated name of the fourth day of the week
56 ABDAY_5 LC_TIME Abbreviated name of the fifth day of the week
57 ABDAY_6 LC_TIME Abbreviated name of the sixth day of the week
58 ABDAY_7 LC_TIME Abbreviated name of the seventh day of the week
59 MON_1   LC_TIME Name of the first month of the year
60 MON_2   LC_TIME Name of the second month
61 MON_3   LC_TIME Name of the third month
62 MON_4   LC_TIME Name of the fourth month
63 MON_5   LC_TIME Name of the fifth month
64 MON_6   LC_TIME Name of the sixth month
65 MON_7   LC_TIME Name of the seventh month
66 MON_8   LC_TIME Name of the eighth month
67 MON_9   LC_TIME Name of the ninth month
68 MON_10  LC_TIME Name of the tenth month
69 MON_11  LC_TIME Name of the eleventh month
70 MON_12  LC_TIME Name of the twelfth month
71 ABMON_1 LC_TIME Abbreviated name of the first month
72 ABMON_2 LC_TIME Abbreviated name of the second month
73 ABMON_3 LC_TIME Abbreviated name of the third month
74 ABMON_4 LC_TIME Abbreviated name of the fourth month
75 ABMON_5 LC_TIME Abbreviated name of the fifth month
76 ABMON_6 LC_TIME Abbreviated name of the sixth month
77 ABMON_7 LC_TIME Abbreviated name of the seventh month
78 ABMON_8 LC_TIME Abbreviated name of the eighth month
79 ABMON_9 LC_TIME Abbreviated name of the ninth month
80 ABMON_10        LC_TIME Abbreviated name of the tenth month
81 ABMON_11        LC_TIME Abbreviated name of the eleventh month
82 ABMON_12        LC_TIME Abbreviated name of the twelfth month
83 ERA     LC_TIME Era description segments
84 ERA_D_FMT       LC_TIME Era date format string
85 ERA_D_T_FMT     LC_TIME Era date and time format string
86 ERA_T_FMT       LC_TIME Era time format string
87 ALT_DIGITS      LC_TIME Alternative symbols for digits
88 RADIXCHAR       LC_NUMERIC      Radix character
89 THOUSEP LC_NUMERIC      Separator for thousands
90 YESEXPR LC_MESSAGES     Affirmative response expression
91 NOEXPR  LC_MESSAGES     Negative response expression
92 .\" CRNCYSTR    LC_MONETARY     Local currency symbol
93 .fi
94 .Sh RETURN VALUES
95 .Fn nl_langinfo
96 returns a pointer to an empty string if
97 .Fa item
98 is invalid.
99 .Sh EXAMPLES
100 The following example uses
101 .Fn nl_langinfo
102 to obtain the date and time format for the current locale:
103 .Bd -literal -offset indent
104 #include <time.h>
105 #include <langinfo.h>
106 #include <locale.h>
107
108 int main(void)
109 {
110         char datestring[100];
111         struct tm *tm;
112         time_t t;
113         char *ptr;
114
115         t = time(NULL);
116         tm = localtime(&t);
117         (void)setlocale(LC_ALL, "");
118         ptr = nl_langinfo(D_T_FMT);
119         strftime(datestring, sizeof(datestring), ptr, tm);
120         printf("%s\en",datestring);
121         return (0);
122 }
123 .Ed
124 .\" .Pp
125 .\" The following example uses
126 .\" .Fn nl_langinfo
127 .\" to obtain the setting of the currency symbol for the current locale:
128 .\" .Pp
129 .\" .Bd
130 .\"     #include <langinfo.h>
131 .\"     #include <locale.h>
132 .\"     int main(void)
133 .\"     {
134 .\"             char *ptr;
135 .\"             (void)setlocale(LC_ALL, "");
136 .\"             ptr = nl_langinfo(CRNCYSTR);
137 .\"             printf("%s", ptr);
138 .\"     }
139 .\" .Ed
140 .Sh SEE ALSO
141 .Xr setlocale 3 ,
142 .Xr nls 7
143 .Sh STANDARDS
144 The
145 .Fn nl_langinfo
146 function conforms to
147 .St -p1003.1-2001 .
148 .Sh HISTORY
149 The
150 .Fn nl_langinfo
151 function appeared in
152 .Nx 1.0 .