1 .\" Copyright (c) 2001 Markus Kuhn <mkuhn@acm.org>
2 .\" and Copyright (c) 2015 Sam Varshavchik <mrsam@courier-mta.com>
3 .\" and Copyright (c) 2015 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
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.
12 .\" References consulted:
13 .\" GNU glibc-2 manual
14 .\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
16 .\" Corrected prototype, 2002-10-18, aeb
18 .TH NL_LANGINFO 3 2021-03-22 "GNU" "Linux Programmer's Manual"
20 nl_langinfo, nl_langinfo_l \- query language and locale information
23 .B #include <langinfo.h>
25 .BI "char *nl_langinfo(nl_item " item );
26 .BI "char *nl_langinfo_l(nl_item " item ", locale_t " locale );
30 Feature Test Macro Requirements for glibc (see
31 .BR feature_test_macros (7)):
37 _POSIX_C_SOURCE >= 200809L
38 Glibc 2.23 and earlier:
39 _POSIX_C_SOURCE >= 200112L
46 functions provide access to locale information
47 in a more flexible way than
50 returns a string which is the value corresponding to
51 \fIitem\fP in the program's current global
54 returns a string which is the value corresponding to \fIitem\fP
55 for the locale identified by the locale object \fIlocale\fP,
56 which was previously created by
58 Individual and additional elements of the locale categories can
61 Examples for the locale elements that can be specified in \fIitem\fP
62 using the constants defined in \fI<langinfo.h>\fP are:
64 .BR CODESET \ (LC_CTYPE)
65 Return a string with the name of the character encoding used in the
66 selected locale, such as "UTF-8", "ISO-8859-1", or "ANSI_X3.4-1968"
67 (better known as US-ASCII).
68 This is the same string that you get with
70 For a list of character encoding names,
74 .BR D_T_FMT \ (LC_TIME)
75 Return a string that can be used as a format string for
77 to represent time and date in a locale-specific way
79 conversion specification).
82 Return a string that can be used as a format string for
84 to represent a date in a locale-specific way
86 conversion specification).
89 Return a string that can be used as a format string for
91 to represent a time in a locale-specific way
93 conversion specification).
95 .BR AM_STR \ (LC_TIME)
96 Return a string that represents affix for ante meridiem (before noon, "AM")
101 conversion specification.)
103 .BR PM_STR \ (LC_TIME)
104 Return a string that represents affix for post meridiem (before midnight, "PM")
109 conversion specification.)
111 .BR T_FMT_AMPM \ (LC_TIME)
112 Return a string that can be used as a format string for
114 to represent a time in a.m. or p.m. notation in a locale-specific way
116 conversion specification).
119 Return era description, which contains information about how years are counted
120 and displayed for each era in a locale.
121 Each era description segment shall have the format:
124 .IR direction : offset : start_date : end_date : era_name : era_format
127 according to the definitions below:
132 .RB \[dq] + "\[dq] or a \[dq]" - \[dq]
136 means that years increase from the
144 The epoch year of the
151 .IR yyyy ", " mm ", and " dd
152 are the year, month, and day numbers respectively of the start of the era.
155 The ending date of the era, in the same format as the
157 or one of the two special values
164 The name of the era, corresponding to the
167 conversion specification.
170 The format of the year in the era, corresponding to the
173 conversion specification.
176 Era description segments are separated by semicolons.
177 Most locales do not define this value.
178 Examples of locales that do define this value are the Japanese and Thai
181 .BR ERA_D_T_FMT \ (LC_TIME)
182 Return a string that can be used as a format string for
184 for alternative representation of time and date in a locale-specific way
186 conversion specification).
188 .BR ERA_D_FMT \ (LC_TIME)
189 Return a string that can be used as a format string for
191 for alternative representation of a date in a locale-specific way
193 conversion specification).
195 .BR ERA_T_FMT \ (LC_TIME)
196 Return a string that can be used as a format string for
198 for alternative representation of a time in a locale-specific way
200 conversion specification).
202 .BR DAY_ "{1\(en7} (LC_TIME)"
203 Return name of the \fIn\fP-th day of the week. [Warning: this follows
204 the US convention DAY_1 = Sunday, not the international convention
205 (ISO 8601) that Monday is the first day of the week.]
209 conversion specification.)
211 .BR ABDAY_ "{1\(en7} (LC_TIME)"
212 Return abbreviated name of the \fIn\fP-th day of the week.
216 conversion specification.)
218 .BR MON_ "{1\(en12} (LC_TIME)"
219 Return name of the \fIn\fP-th month.
223 conversion specification.)
225 .BR ABMON_ "{1\(en12} (LC_TIME)"
226 Return abbreviated name of the \fIn\fP-th month.
230 conversion specification.)
232 .BR RADIXCHAR \ (LC_NUMERIC)
233 Return radix character (decimal dot, decimal comma, etc.).
235 .BR THOUSEP \ (LC_NUMERIC)
236 Return separator character for thousands (groups of three digits).
238 .BR YESEXPR \ (LC_MESSAGES)
239 Return a regular expression that can be used with the
241 function to recognize a positive response to a yes/no question.
243 .BR NOEXPR \ (LC_MESSAGES)
244 Return a regular expression that can be used with the
246 function to recognize a negative response to a yes/no question.
248 .BR CRNCYSTR \ (LC_MONETARY)
249 Return the currency symbol, preceded by "\-" if the symbol should
250 appear before the value, "+" if the symbol should appear after the
251 value, or "." if the symbol should replace the radix character.
253 The above list covers just some examples of items that can be requested.
254 For a more detailed list, consult
255 .IR "The GNU C Library Reference Manual" .
257 On success, these functions return a pointer to a string which
258 is the value corresponding to
260 in the specified locale.
262 If no locale has been selected by
264 for the appropriate category,
266 return a pointer to the corresponding string in the "C" locale.
271 specifies a locale where
275 If \fIitem\fP is not valid, a pointer to an empty string is returned.
277 The pointer returned by these functions may point to static data that
278 may be overwritten, or the pointer itself may be invalidated,
279 by a subsequent call to
281 .BR nl_langinfo_l (),
284 The same statements apply to
286 if the locale object referred to by
288 is freed or modified by
293 POSIX specifies that the application may not modify
294 the string returned by these functions.
296 For an explanation of the terms used in this section, see
304 Interface Attribute Value
307 T} Thread safety MT-Safe locale
313 POSIX.1-2001, POSIX.1-2008, SUSv2.
319 is the special locale object
321 or is not a valid locale object handle.
323 The following program sets the character type and the numeric locale
324 according to the environment and queries the terminal character set and
328 #include <langinfo.h>
334 main(int argc, char *argv[])
336 setlocale(LC_CTYPE, "");
337 setlocale(LC_NUMERIC, "");
339 printf("%s\en", nl_langinfo(CODESET));
340 printf("%s\en", nl_langinfo(RADIXCHAR));
352 The GNU C Library Reference Manual