]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright (c) 2001 Markus Kuhn <mkuhn@acm.org> |
80bf84f6 MK |
2 | .\" and Copyright (c) 2015 Sam Varshavchik <mrsam@courier-mta.com> |
3 | .\" and Copyright (c) 2015 Michael Kerrisk <mtk.manpages@gmail.com> | |
fea681da | 4 | .\" |
89e3ffe9 | 5 | .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA) |
fea681da MK |
6 | .\" This is free documentation; you can redistribute it and/or |
7 | .\" modify it under the terms of the GNU General Public License as | |
8 | .\" published by the Free Software Foundation; either version 2 of | |
9 | .\" the License, or (at your option) any later version. | |
8f8359d8 | 10 | .\" %%%LICENSE_END |
fea681da MK |
11 | .\" |
12 | .\" References consulted: | |
13 | .\" GNU glibc-2 manual | |
008f1ecc | 14 | .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html |
fea681da MK |
15 | .\" |
16 | .\" Corrected prototype, 2002-10-18, aeb | |
17 | .\" | |
4b8c67d9 | 18 | .TH NL_LANGINFO 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da | 19 | .SH NAME |
665d98c5 | 20 | nl_langinfo, nl_langinfo_l \- query language and locale information |
fea681da MK |
21 | .SH SYNOPSIS |
22 | .nf | |
23 | .B #include <langinfo.h> | |
68e4db0a | 24 | .PP |
fea681da | 25 | .BI "char *nl_langinfo(nl_item " item ); |
68e4db0a | 26 | .PP |
665d98c5 | 27 | .BI "char *nl_langinfo_l(nl_item " item ", locale_t " locale ); |
fea681da | 28 | .fi |
68e4db0a | 29 | .PP |
4c931ba3 MK |
30 | .in -4n |
31 | Feature Test Macro Requirements for glibc (see | |
32 | .BR feature_test_macros (7)): | |
33 | .in | |
68e4db0a | 34 | .PP |
4c931ba3 MK |
35 | .ad l |
36 | .BR nl_langinfo_l (): | |
37 | .RS 4 | |
38 | Since glibc 2.24: | |
39 | _POSIX_C_SOURCE\ >=\ 200809L | |
40 | .br | |
41 | Glibc 2.23 and earlier: | |
42 | _POSIX_C_SOURCE\ >=\ 200112L | |
43 | .RE | |
44 | .ad b | |
fea681da | 45 | .SH DESCRIPTION |
60a90ecd MK |
46 | The |
47 | .BR nl_langinfo () | |
665d98c5 SV |
48 | and |
49 | .BR nl_langinfo_l () | |
50 | functions provide access to locale information | |
fea681da | 51 | in a more flexible way than |
83a366e0 | 52 | .BR localeconv (3). |
665d98c5 | 53 | .BR nl_langinfo() |
1f741719 MK |
54 | returns a string which is the value corresponding to |
55 | \fIitem\fP in the program's current global | |
665d98c5 SV |
56 | locale. |
57 | .BR nl_langinfo() | |
1f741719 MK |
58 | returns a string which is the value corresponding to \fIitem\fP |
59 | for the locale identified by the locale object \fIlocale\fP, | |
83a366e0 | 60 | which was previously created by |
665d98c5 | 61 | .BR newlocale (1). |
c13182ef | 62 | Individual and additional elements of the locale categories can |
fea681da MK |
63 | be queried. |
64 | .PP | |
65 | Examples for the locale elements that can be specified in \fIitem\fP | |
c84371c6 | 66 | using the constants defined in \fI<langinfo.h>\fP are: |
fea681da MK |
67 | .TP |
68 | .BR CODESET \ (LC_CTYPE) | |
69 | Return a string with the name of the character encoding used in the | |
70 | selected locale, such as "UTF-8", "ISO-8859-1", or "ANSI_X3.4-1968" | |
c13182ef MK |
71 | (better known as US-ASCII). |
72 | This is the same string that you get with | |
73 | "locale charmap". | |
74 | For a list of character encoding names, | |
9ab7f611 BR |
75 | try "locale \-m" (see |
76 | .BR locale (1)). | |
fea681da MK |
77 | .TP |
78 | .BR D_T_FMT \ (LC_TIME) | |
79 | Return a string that can be used as a format string for | |
80 | .BR strftime (3) | |
81 | to represent time and date in a locale-specific way. | |
fea681da MK |
82 | .TP |
83 | .BR D_FMT \ (LC_TIME) | |
84 | Return a string that can be used as a format string for | |
85 | .BR strftime (3) | |
86 | to represent a date in a locale-specific way. | |
fea681da MK |
87 | .TP |
88 | .BR T_FMT \ (LC_TIME) | |
89 | Return a string that can be used as a format string for | |
90 | .BR strftime (3) | |
91 | to represent a time in a locale-specific way. | |
fea681da MK |
92 | .TP |
93 | .BR DAY_ "{1\(en7} (LC_TIME)" | |
94 | Return name of the \fIn\fP-th day of the week. [Warning: this follows | |
95 | the US convention DAY_1 = Sunday, not the international convention | |
96 | (ISO 8601) that Monday is the first day of the week.] | |
fea681da MK |
97 | .TP |
98 | .BR ABDAY_ "{1\(en7} (LC_TIME)" | |
99 | Return abbreviated name of the \fIn\fP-th day of the week. | |
fea681da MK |
100 | .TP |
101 | .BR MON_ "{1\(en12} (LC_TIME)" | |
102 | Return name of the \fIn\fP-th month. | |
fea681da MK |
103 | .TP |
104 | .BR ABMON_ "{1\(en12} (LC_TIME)" | |
105 | Return abbreviated name of the \fIn\fP-th month. | |
fea681da MK |
106 | .TP |
107 | .BR RADIXCHAR \ (LC_NUMERIC) | |
108 | Return radix character (decimal dot, decimal comma, etc.). | |
fea681da MK |
109 | .TP |
110 | .BR THOUSEP \ (LC_NUMERIC) | |
111 | Return separator character for thousands (groups of three digits). | |
fea681da | 112 | .TP |
c13182ef MK |
113 | .BR YESEXPR \ (LC_MESSAGES) |
114 | Return a regular expression that can be used with the | |
fea681da MK |
115 | .BR regex (3) |
116 | function to recognize a positive response to a yes/no question. | |
fea681da | 117 | .TP |
c13182ef MK |
118 | .BR NOEXPR \ (LC_MESSAGES) |
119 | Return a regular expression that can be used with the | |
fea681da MK |
120 | .BR regex (3) |
121 | function to recognize a negative response to a yes/no question. | |
fea681da MK |
122 | .TP |
123 | .BR CRNCYSTR \ (LC_MONETARY) | |
124 | Return the currency symbol, preceded by "\-" if the symbol should | |
125 | appear before the value, "+" if the symbol should appear after the | |
126 | value, or "." if the symbol should replace the radix character. | |
127 | .PP | |
c13182ef | 128 | The above list covers just some examples of items that can be requested. |
64dd3207 | 129 | For a more detailed list, consult |
fea681da | 130 | .IR "The GNU C Library Reference Manual" . |
47297adb | 131 | .SH RETURN VALUE |
7003ff6a MK |
132 | On success, these functions return a pointer to a string which |
133 | is the value corresponding to | |
134 | .I item | |
135 | in the specified locale. | |
847e0d88 | 136 | .PP |
7b937140 | 137 | If no locale has been selected by |
0b80cf56 | 138 | .BR setlocale (3) |
7b937140 | 139 | for the appropriate category, |
60a90ecd | 140 | .BR nl_langinfo () |
29f6f82c MK |
141 | return a pointer to the corresponding string in the "C" locale. |
142 | The same is true of | |
665d98c5 | 143 | .BR nl_langinfo_l () |
29f6f82c MK |
144 | if |
145 | .I locale | |
146 | specifies a locale where | |
147 | .I langinfo | |
148 | data is not defined. | |
fea681da MK |
149 | .PP |
150 | If \fIitem\fP is not valid, a pointer to an empty string is returned. | |
151 | .PP | |
cc331dfc MK |
152 | The pointer returned by these functions may point to static data that |
153 | may be overwritten, or the pointer itself may be invalidated, | |
154 | by a subsequent call to | |
155 | .BR nl_langinfo (), | |
156 | .BR nl_langinfo_l (), | |
60a90ecd | 157 | or |
3a72373c | 158 | .BR setlocale (3). |
cc331dfc MK |
159 | The same statements apply to |
160 | .BR nl_langinfo_l () | |
161 | if the locale object referred to by | |
162 | .I locale | |
163 | is freed or modified by | |
164 | .BR freelocale (3) | |
165 | or | |
166 | .BR newlocale (3). | |
847e0d88 | 167 | .PP |
75b3623d MK |
168 | POSIX specifies that the application may not modify |
169 | the string returned by these functions. | |
52aacd78 PH |
170 | .SH ATTRIBUTES |
171 | For an explanation of the terms used in this section, see | |
172 | .BR attributes (7). | |
173 | .TS | |
174 | allbox; | |
175 | lb lb lb | |
176 | l l l. | |
177 | Interface Attribute Value | |
178 | T{ | |
179 | .BR nl_langinfo () | |
180 | T} Thread safety MT-Safe locale | |
181 | .TE | |
47297adb | 182 | .SH CONFORMING TO |
5b36c0e4 | 183 | POSIX.1-2001, POSIX.1-2008, SUSv2. |
872e754b MK |
184 | .SH NOTES |
185 | The behavior of | |
186 | .BR nl_langinfo_l () | |
187 | is undefined if | |
188 | .I locale | |
189 | is the special locale object | |
190 | .BR LC_GLOBAL_LOCALE | |
191 | or is not a valid locale object handle. | |
47297adb | 192 | .SH EXAMPLE |
dbe0246b MM |
193 | The following program sets the character type and the numeric locale |
194 | according to the environment and queries the terminal character set and | |
195 | the radix character. | |
dd3568a1 | 196 | .PP |
207050fa | 197 | .EX |
7f3e079f MH |
198 | #include <langinfo.h> |
199 | #include <locale.h> | |
200 | #include <stdio.h> | |
201 | #include <stdlib.h> | |
202 | ||
203 | int | |
204 | main(int argc, char *argv[]) | |
205 | { | |
68f4e1fd | 206 | setlocale(LC_CTYPE, ""); |
dbe0246b | 207 | setlocale(LC_NUMERIC, ""); |
c607c3a6 | 208 | |
68f4e1fd | 209 | printf("%s\\n", nl_langinfo(CODESET)); |
dbe0246b | 210 | printf("%s\\n", nl_langinfo(RADIXCHAR)); |
c607c3a6 | 211 | |
7f3e079f MH |
212 | exit(EXIT_SUCCESS); |
213 | } | |
207050fa | 214 | .EE |
47297adb | 215 | .SH SEE ALSO |
fea681da MK |
216 | .BR locale (1), |
217 | .BR localeconv (3), | |
218 | .BR setlocale (3), | |
219 | .BR charsets (7), | |
883b0fef | 220 | .BR locale (7) |
207050fa | 221 | .PP |
fea681da | 222 | The GNU C Library Reference Manual |