xref: /netbsd-src/lib/libc/locale/nl_langinfo.3 (revision daf6c4152fcddc27c445489775ed1f66ab4ea9a9)
1.\"	$NetBSD: nl_langinfo.3,v 1.19 2010/03/22 19:30:54 joerg Exp $
2.\"
3.\" Written by J.T. Conklin <jtc@NetBSD.org>.
4.\" Public domain.
5.\"
6.Dd February 12, 2003
7.Dt NL_LANGINFO 3
8.Os
9.Sh NAME
10.Nm nl_langinfo
11.Nd get locale information
12.Sh LIBRARY
13.Lb libc
14.Sh SYNOPSIS
15.In langinfo.h
16.Ft char *
17.Fn nl_langinfo "nl_item item"
18.Sh DESCRIPTION
19The
20.Fn nl_langinfo
21function returns a pointer to a string containing information
22set by the program's locale.
23.Pp
24The names and values of
25.Fa item
26are defined in
27.In langinfo.h .
28The entries under Category indicate in which
29.Xr setlocale 3
30category 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
88.El
89.Sh RETURN VALUES
90.Fn nl_langinfo
91returns a pointer to an empty string if
92.Fa item
93is invalid.
94.Sh EXAMPLES
95The following example uses
96.Fn nl_langinfo
97to obtain the date and time format for the current locale:
98.Pp
99.Bd -literal -offset indent
100#include \*[Lt]time.h\*[Gt]
101#include \*[Lt]langinfo.h\*[Gt]
102#include \*[Lt]locale.h\*[Gt]
103
104int main(void)
105{
106	char datestring[100];
107	struct tm *tm;
108	time_t t;
109	char *ptr;
110
111	t = time(NULL);
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);
117	return (0);
118}
119.Ed
120.\" .Pp
121.\" The following example uses
122.\" .Fn nl_langinfo
123.\" to obtain the setting of the currency symbol for the current locale:
124.\" .Pp
125.\" .Bd
126.\" 	#include \*[Lt]langinfo.h\*[Gt]
127.\" 	#include \*[Lt]locale.h\*[Gt]
128.\" 	int main(void)
129.\" 	{
130.\" 		char *ptr;
131.\" 		(void)setlocale(LC_ALL, "");
132.\" 		ptr = nl_langinfo(CRNCYSTR);
133.\" 		printf("%s", ptr);
134.\" 	}
135.\" .Ed
136.Sh SEE ALSO
137.Xr setlocale 3 ,
138.Xr nls 7
139.Sh STANDARDS
140The
141.Fn nl_langinfo
142function conforms to
143.St -p1003.1-2001 .
144.Sh HISTORY
145The
146.Fn nl_langinfo
147function appeared in
148.Nx 1.0 .
149