Tue Dec 15 00:35:36 2009 UTC ()
Put space after comma in the C code example.


(enami)
diff -r1.17 -r1.18 src/lib/libc/locale/nl_langinfo.3

cvs diff -r1.17 -r1.18 src/lib/libc/locale/nl_langinfo.3 (switch to unified diff)

--- src/lib/libc/locale/nl_langinfo.3 2009/03/12 12:50:31 1.17
+++ src/lib/libc/locale/nl_langinfo.3 2009/12/15 00:35:36 1.18
@@ -1,148 +1,148 @@ @@ -1,148 +1,148 @@
1.\" $NetBSD: nl_langinfo.3,v 1.17 2009/03/12 12:50:31 joerg Exp $ 1.\" $NetBSD: nl_langinfo.3,v 1.18 2009/12/15 00:35:36 enami Exp $
2.\" 2.\"
3.\" Written by J.T. Conklin <jtc@NetBSD.org>. 3.\" Written by J.T. Conklin <jtc@NetBSD.org>.
4.\" Public domain. 4.\" Public domain.
5.\" 5.\"
6.Dd February 12, 2003 6.Dd February 12, 2003
7.Dt NL_LANGINFO 3 7.Dt NL_LANGINFO 3
8.Os 8.Os
9.Sh NAME 9.Sh NAME
10.Nm nl_langinfo 10.Nm nl_langinfo
11.Nd get locale information 11.Nd get locale information
12.Sh LIBRARY 12.Sh LIBRARY
13.Lb libc 13.Lb libc
14.Sh SYNOPSIS 14.Sh SYNOPSIS
15.In langinfo.h 15.In langinfo.h
16.Ft char * 16.Ft char *
17.Fn nl_langinfo "nl_item item" 17.Fn nl_langinfo "nl_item item"
18.Sh DESCRIPTION 18.Sh DESCRIPTION
19The 19The
20.Fn nl_langinfo 20.Fn nl_langinfo
21function returns a pointer to a string containing information 21function returns a pointer to a string containing information
22set by the program's locale. 22set by the program's locale.
23.Pp 23.Pp
24The names and values of 24The names and values of
25.Fa item 25.Fa item
26are defined in 26are defined in
27.Aq Pa langinfo.h . 27.Aq Pa langinfo.h .
28The entries under Category indicate in which 28The entries under Category indicate in which
29.Xr setlocale 3 29.Xr setlocale 3
30category each item is defined. 30category each item is defined.
31.Bl -column ERA_D_T_FMT LC_MESSAGES 31.Bl -column ERA_D_T_FMT LC_MESSAGES
32.It Sy Constant Ta Sy Category Ta Sy Meaning 32.It Sy Constant Ta Sy Category Ta Sy Meaning
33.It CODESET LC_CTYPE Codeset name 33.It CODESET LC_CTYPE Codeset name
34.It D_T_FMT LC_TIME String for formatting date and time 34.It D_T_FMT LC_TIME String for formatting date and time
35.It D_FMT LC_TIME Date format string 35.It D_FMT LC_TIME Date format string
36.It T_FMT LC_TIME Time 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 37.It T_FMT_AMPM LC_TIME A.M. or P.M. time format string
38.It AM_STR LC_TIME Ante-meridiem affix 38.It AM_STR LC_TIME Ante-meridiem affix
39.It PM_STR LC_TIME Post-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) 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) 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) 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) 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) 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) 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) 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 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 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 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 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 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 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 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 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 55.It MON_2 LC_TIME Name of the second month
56.It MON_3 LC_TIME Name of the third month 56.It MON_3 LC_TIME Name of the third month
57.It MON_4 LC_TIME Name of the fourth month 57.It MON_4 LC_TIME Name of the fourth month
58.It MON_5 LC_TIME Name of the fifth month 58.It MON_5 LC_TIME Name of the fifth month
59.It MON_6 LC_TIME Name of the sixth month 59.It MON_6 LC_TIME Name of the sixth month
60.It MON_7 LC_TIME Name of the seventh month 60.It MON_7 LC_TIME Name of the seventh month
61.It MON_8 LC_TIME Name of the eighth month 61.It MON_8 LC_TIME Name of the eighth month
62.It MON_9 LC_TIME Name of the ninth month 62.It MON_9 LC_TIME Name of the ninth month
63.It MON_10 LC_TIME Name of the tenth month 63.It MON_10 LC_TIME Name of the tenth month
64.It MON_11 LC_TIME Name of the eleventh month 64.It MON_11 LC_TIME Name of the eleventh month
65.It MON_12 LC_TIME Name of the twelfth month 65.It MON_12 LC_TIME Name of the twelfth month
66.It ABMON_1 LC_TIME Abbreviated name of the first 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 67.It ABMON_2 LC_TIME Abbreviated name of the second month
68.It ABMON_3 LC_TIME Abbreviated name of the third 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 69.It ABMON_4 LC_TIME Abbreviated name of the fourth month
70.It ABMON_5 LC_TIME Abbreviated name of the fifth 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 71.It ABMON_6 LC_TIME Abbreviated name of the sixth month
72.It ABMON_7 LC_TIME Abbreviated name of the seventh 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 73.It ABMON_8 LC_TIME Abbreviated name of the eighth month
74.It ABMON_9 LC_TIME Abbreviated name of the ninth 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 75.It ABMON_10 LC_TIME Abbreviated name of the tenth month
76.It ABMON_11 LC_TIME Abbreviated name of the eleventh 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 77.It ABMON_12 LC_TIME Abbreviated name of the twelfth month
78.It ERA LC_TIME Era description segments 78.It ERA LC_TIME Era description segments
79.It ERA_D_FMT LC_TIME Era date format string 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 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 81.It ERA_T_FMT LC_TIME Era time format string
82.It ALT_DIGITS LC_TIME Alternative symbols for digits 82.It ALT_DIGITS LC_TIME Alternative symbols for digits
83.It RADIXCHAR LC_NUMERIC Radix character 83.It RADIXCHAR LC_NUMERIC Radix character
84.It THOUSEP LC_NUMERIC Separator for thousands 84.It THOUSEP LC_NUMERIC Separator for thousands
85.It YESEXPR LC_MESSAGES Affirmative response expression 85.It YESEXPR LC_MESSAGES Affirmative response expression
86.It NOEXPR LC_MESSAGES Negative response expression 86.It NOEXPR LC_MESSAGES Negative response expression
87.\".It CRNCYSTR LC_MONETARY Local currency symbol 87.\".It CRNCYSTR LC_MONETARY Local currency symbol
88.El 88.El
89.Sh RETURN VALUES 89.Sh RETURN VALUES
90.Fn nl_langinfo 90.Fn nl_langinfo
91returns a pointer to an empty string if 91returns a pointer to an empty string if
92.Fa item 92.Fa item
93is invalid. 93is invalid.
94.Sh EXAMPLES 94.Sh EXAMPLES
95The following example uses 95The following example uses
96.Fn nl_langinfo 96.Fn nl_langinfo
97to obtain the date and time format for the current locale: 97to obtain the date and time format for the current locale:
98.Pp 98.Pp
99.Bd -literal -offset indent 99.Bd -literal -offset indent
100#include \*[Lt]time.h\*[Gt] 100#include \*[Lt]time.h\*[Gt]
101#include \*[Lt]langinfo.h\*[Gt] 101#include \*[Lt]langinfo.h\*[Gt]
102#include \*[Lt]locale.h\*[Gt] 102#include \*[Lt]locale.h\*[Gt]
103 103
104int main(void) 104int main(void)
105{ 105{
106 char datestring[100]; 106 char datestring[100];
107 struct tm *tm; 107 struct tm *tm;
108 time_t t; 108 time_t t;
109 char *ptr; 109 char *ptr;
110 110
111 t = time(NULL); 111 t = time(NULL);
112 tm = localtime(\*[Am]t); 112 tm = localtime(\*[Am]t);
113 (void)setlocale(LC_ALL, ""); 113 (void)setlocale(LC_ALL, "");
114 ptr = nl_langinfo(D_T_FMT); 114 ptr = nl_langinfo(D_T_FMT);
115 strftime(datestring, sizeof(datestring), ptr, tm); 115 strftime(datestring, sizeof(datestring), ptr, tm);
116 printf("%s\en",datestring); 116 printf("%s\en", datestring);
117 return (0); 117 return (0);
118} 118}
119.Ed 119.Ed
120.\" .Pp 120.\" .Pp
121.\" The following example uses 121.\" The following example uses
122.\" .Fn nl_langinfo 122.\" .Fn nl_langinfo
123.\" to obtain the setting of the currency symbol for the current locale: 123.\" to obtain the setting of the currency symbol for the current locale:
124.\" .Pp 124.\" .Pp
125.\" .Bd 125.\" .Bd
126.\" #include \*[Lt]langinfo.h\*[Gt] 126.\" #include \*[Lt]langinfo.h\*[Gt]
127.\" #include \*[Lt]locale.h\*[Gt] 127.\" #include \*[Lt]locale.h\*[Gt]
128.\" int main(void) 128.\" int main(void)
129.\" { 129.\" {
130.\" char *ptr; 130.\" char *ptr;
131.\" (void)setlocale(LC_ALL, ""); 131.\" (void)setlocale(LC_ALL, "");
132.\" ptr = nl_langinfo(CRNCYSTR); 132.\" ptr = nl_langinfo(CRNCYSTR);
133.\" printf("%s", ptr); 133.\" printf("%s", ptr);
134.\" } 134.\" }
135.\" .Ed 135.\" .Ed
136.Sh SEE ALSO 136.Sh SEE ALSO
137.Xr setlocale 3 , 137.Xr setlocale 3 ,
138.Xr nls 7 138.Xr nls 7
139.Sh STANDARDS 139.Sh STANDARDS
140The 140The
141.Fn nl_langinfo 141.Fn nl_langinfo
142function conforms to 142function conforms to
143.St -p1003.1-2001 . 143.St -p1003.1-2001 .
144.Sh HISTORY 144.Sh HISTORY
145The 145The
146.Fn nl_langinfo 146.Fn nl_langinfo
147function appeared in 147function appeared in
148.Nx 1.0 . 148.Nx 1.0 .