xref: /netbsd-src/lib/libc/locale/nl_langinfo.3 (revision 8ac07aec990b9d2e483062509d0a9fa5b4f57cf2)
1.\"	$NetBSD: nl_langinfo.3,v 1.16 2006/08/08 17:31:35 wiz 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.Aq Pa langinfo.h .
28The entries under Category indicate in which
29.Xr setlocale 3
30category each item is defined.
31.sp
32.nf
33.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
34\fIConstant\fP	\fICategory\fP	\fIMeaning\fP
35.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
36.sp 5p
37CODESET	LC_CTYPE	Codeset name
38D_T_FMT	LC_TIME	String for formatting date and time
39D_FMT	LC_TIME	Date format string
40T_FMT	LC_TIME	Time format string
41T_FMT_AMPM	LC_TIME	A.M. or P.M. time format string
42AM_STR	LC_TIME	Ante-meridiem affix
43PM_STR	LC_TIME	Post-meridiem affix
44DAY_1	LC_TIME	Name of the first day of the week (e.g.: Sunday)
45DAY_2	LC_TIME	Name of the second day of the week (e.g.: Monday)
46DAY_3	LC_TIME	Name of the third day of the week (e.g.: Tuesday)
47DAY_4	LC_TIME	Name of the fourth day of the week (e.g.: Wednesday)
48DAY_5	LC_TIME	Name of the fifth day of the week (e.g.: Thursday)
49DAY_6	LC_TIME	Name of the sixth day of the week (e.g.: Friday)
50DAY_7	LC_TIME	Name of the seventh day of the week (e.g.: Saturday)
51ABDAY_1	LC_TIME	Abbreviated name of the first day of the week
52ABDAY_2	LC_TIME	Abbreviated name of the second day of the week
53ABDAY_3	LC_TIME	Abbreviated name of the third day of the week
54ABDAY_4	LC_TIME	Abbreviated name of the fourth day of the week
55ABDAY_5	LC_TIME	Abbreviated name of the fifth day of the week
56ABDAY_6	LC_TIME	Abbreviated name of the sixth day of the week
57ABDAY_7	LC_TIME	Abbreviated name of the seventh day of the week
58MON_1	LC_TIME	Name of the first month of the year
59MON_2	LC_TIME	Name of the second month
60MON_3	LC_TIME	Name of the third month
61MON_4	LC_TIME	Name of the fourth month
62MON_5	LC_TIME	Name of the fifth month
63MON_6	LC_TIME	Name of the sixth month
64MON_7	LC_TIME	Name of the seventh month
65MON_8	LC_TIME	Name of the eighth month
66MON_9	LC_TIME	Name of the ninth month
67MON_10	LC_TIME	Name of the tenth month
68MON_11	LC_TIME	Name of the eleventh month
69MON_12	LC_TIME	Name of the twelfth month
70ABMON_1	LC_TIME	Abbreviated name of the first month
71ABMON_2	LC_TIME	Abbreviated name of the second month
72ABMON_3	LC_TIME	Abbreviated name of the third month
73ABMON_4	LC_TIME	Abbreviated name of the fourth month
74ABMON_5	LC_TIME	Abbreviated name of the fifth month
75ABMON_6	LC_TIME	Abbreviated name of the sixth month
76ABMON_7	LC_TIME	Abbreviated name of the seventh month
77ABMON_8	LC_TIME	Abbreviated name of the eighth month
78ABMON_9	LC_TIME	Abbreviated name of the ninth month
79ABMON_10	LC_TIME	Abbreviated name of the tenth month
80ABMON_11	LC_TIME	Abbreviated name of the eleventh month
81ABMON_12	LC_TIME	Abbreviated name of the twelfth month
82ERA	LC_TIME	Era description segments
83ERA_D_FMT	LC_TIME	Era date format string
84ERA_D_T_FMT	LC_TIME	Era date and time format string
85ERA_T_FMT	LC_TIME	Era time format string
86ALT_DIGITS	LC_TIME	Alternative symbols for digits
87RADIXCHAR	LC_NUMERIC	Radix character
88THOUSEP	LC_NUMERIC	Separator for thousands
89YESEXPR	LC_MESSAGES	Affirmative response expression
90NOEXPR	LC_MESSAGES	Negative response expression
91.\" CRNCYSTR	LC_MONETARY	Local currency symbol
92.fi
93.Sh RETURN VALUES
94.Fn nl_langinfo
95returns a pointer to an empty string if
96.Fa item
97is invalid.
98.Sh EXAMPLES
99The following example uses
100.Fn nl_langinfo
101to obtain the date and time format for the current locale:
102.Pp
103.Bd -literal -offset indent
104#include \*[Lt]time.h\*[Gt]
105#include \*[Lt]langinfo.h\*[Gt]
106#include \*[Lt]locale.h\*[Gt]
107
108int 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(\*[Am]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 \*[Lt]langinfo.h\*[Gt]
131.\" 	#include \*[Lt]locale.h\*[Gt]
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
144The
145.Fn nl_langinfo
146function conforms to
147.St -p1003.1-2001 .
148.Sh HISTORY
149The
150.Fn nl_langinfo
151function appeared in
152.Nx 1.0 .
153