- Uniformly use .In for header file references.
[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.5 2006/05/26 19:39:37 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 .Pp
104 .Bd -literal -offset indent
105 #include <time.h>
106 #include <langinfo.h>
107 #include <locale.h>
108
109 int main(void)
110 {
111         char datestring[100];
112         struct tm *tm;
113         time_t t;
114         char *ptr;
115
116         t = time(NULL);
117         tm = localtime(&t);
118         (void)setlocale(LC_ALL, "");
119         ptr = nl_langinfo(D_T_FMT);
120         strftime(datestring, sizeof(datestring), ptr, tm);
121         printf("%s\en",datestring);
122         return (0);
123 }
124 .Ed
125 .\" .Pp
126 .\" The following example uses
127 .\" .Fn nl_langinfo
128 .\" to obtain the setting of the currency symbol for the current locale:
129 .\" .Pp
130 .\" .Bd
131 .\"     #include <langinfo.h>
132 .\"     #include <locale.h>
133 .\"     int main(void)
134 .\"     {
135 .\"             char *ptr;
136 .\"             (void)setlocale(LC_ALL, "");
137 .\"             ptr = nl_langinfo(CRNCYSTR);
138 .\"             printf("%s", ptr);
139 .\"     }
140 .\" .Ed
141 .Sh SEE ALSO
142 .Xr setlocale 3 ,
143 .Xr nls 7
144 .Sh STANDARDS
145 The
146 .Fn nl_langinfo
147 function conforms to
148 .St -p1003.1-2001 .
149 .Sh HISTORY
150 The
151 .Fn nl_langinfo
152 function appeared in
153 .Nx 1.0 .