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 2020-04-11 "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 );
27 .BI "char *nl_langinfo_l(nl_item " item ", locale_t " locale );
31 Feature Test Macro Requirements for glibc (see
32 .BR feature_test_macros (7)):
39 _POSIX_C_SOURCE\ >=\ 200809L
41 Glibc 2.23 and earlier:
42 _POSIX_C_SOURCE\ >=\ 200112L
50 functions provide access to locale information
51 in a more flexible way than
54 returns a string which is the value corresponding to
55 \fIitem\fP in the program's current global
58 returns a string which is the value corresponding to \fIitem\fP
59 for the locale identified by the locale object \fIlocale\fP,
60 which was previously created by
62 Individual and additional elements of the locale categories can
65 Examples for the locale elements that can be specified in \fIitem\fP
66 using the constants defined in \fI<langinfo.h>\fP are:
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"
71 (better known as US-ASCII).
72 This is the same string that you get with
74 For a list of character encoding names,
78 .BR D_T_FMT \ (LC_TIME)
79 Return a string that can be used as a format string for
81 to represent time and date in a locale-specific way
83 conversion specification).
86 Return a string that can be used as a format string for
88 to represent a date in a locale-specific way
90 conversion specification).
93 Return a string that can be used as a format string for
95 to represent a time in a locale-specific way
97 conversion specification).
99 .BR AM_STR \ (LC_TIME)
100 Return a string that represents affix for ante meridiem (before noon, "AM")
105 conversion specification.)
107 .BR PM_STR \ (LC_TIME)
108 Return a string that represents affix for post meridiem (before midnight, "PM")
113 conversion specification.)
115 .BR T_FMT_AMPM \ (LC_TIME)
116 Return a string that can be used as a format string for
118 to represent a time in a.m. or p.m. notation a locale-specific way
120 conversion specification).
123 Return era description, which contains information about how years are counted
124 and displayed for each era in a locale.
125 Each era description segment shall have the format:
128 .IR direction : offset : start_date : end_date : era_name : era_format
131 according to the definitions below:
136 .RB \[dq] + "\[dq] or a \[dq]" - \[dq]
140 means that years increase from the
148 The epoch year of the
155 .IR yyyy ", " mm ", and " dd
156 are the year, month, and day numbers respectively of the start of the era.
159 The ending date of the era, in the same format as the
161 or one of the two special values
168 The name of the era, corresponding to the
171 conversion specification.
174 The format of the year in the era, corresponding to the
177 conversion specification.
180 Era description segments are separated by semicolons.
181 Most locales do not define this value.
182 Examples of locales that do define this value are the Japanese and Thai
185 .BR ERA_D_T_FMT \ (LC_TIME)
186 Return a string that can be used as a format string for
188 for alternative representation of time and date in a locale-specific way
190 conversion specification).
192 .BR ERA_D_FMT \ (LC_TIME)
193 Return a string that can be used as a format string for
195 for alternative representation of a date in a locale-specific way
197 conversion specification).
199 .BR ERA_T_FMT \ (LC_TIME)
200 Return a string that can be used as a format string for
202 for alternative representation of a time in a locale-specific way
204 conversion specification).
206 .BR DAY_ "{1\(en7} (LC_TIME)"
207 Return name of the \fIn\fP-th day of the week. [Warning: this follows
208 the US convention DAY_1 = Sunday, not the international convention
209 (ISO 8601) that Monday is the first day of the week.]
213 conversion specification.)
215 .BR ABDAY_ "{1\(en7} (LC_TIME)"
216 Return abbreviated name of the \fIn\fP-th day of the week.
220 conversion specification.)
222 .BR MON_ "{1\(en12} (LC_TIME)"
223 Return name of the \fIn\fP-th month.
227 conversion specification.)
229 .BR ABMON_ "{1\(en12} (LC_TIME)"
230 Return abbreviated name of the \fIn\fP-th month.
234 conversion specification.)
236 .BR RADIXCHAR \ (LC_NUMERIC)
237 Return radix character (decimal dot, decimal comma, etc.).
239 .BR THOUSEP \ (LC_NUMERIC)
240 Return separator character for thousands (groups of three digits).
242 .BR YESEXPR \ (LC_MESSAGES)
243 Return a regular expression that can be used with the
245 function to recognize a positive response to a yes/no question.
247 .BR NOEXPR \ (LC_MESSAGES)
248 Return a regular expression that can be used with the
250 function to recognize a negative response to a yes/no question.
252 .BR CRNCYSTR \ (LC_MONETARY)
253 Return the currency symbol, preceded by "\-" if the symbol should
254 appear before the value, "+" if the symbol should appear after the
255 value, or "." if the symbol should replace the radix character.
257 The above list covers just some examples of items that can be requested.
258 For a more detailed list, consult
259 .IR "The GNU C Library Reference Manual" .
261 On success, these functions return a pointer to a string which
262 is the value corresponding to
264 in the specified locale.
266 If no locale has been selected by
268 for the appropriate category,
270 return a pointer to the corresponding string in the "C" locale.
275 specifies a locale where
279 If \fIitem\fP is not valid, a pointer to an empty string is returned.
281 The pointer returned by these functions may point to static data that
282 may be overwritten, or the pointer itself may be invalidated,
283 by a subsequent call to
285 .BR nl_langinfo_l (),
288 The same statements apply to
290 if the locale object referred to by
292 is freed or modified by
297 POSIX specifies that the application may not modify
298 the string returned by these functions.
300 For an explanation of the terms used in this section, see
306 Interface Attribute Value
309 T} Thread safety MT-Safe locale
312 POSIX.1-2001, POSIX.1-2008, SUSv2.
318 is the special locale object
320 or is not a valid locale object handle.
322 The following program sets the character type and the numeric locale
323 according to the environment and queries the terminal character set and
327 #include <langinfo.h>
333 main(int argc, char *argv[])
335 setlocale(LC_CTYPE, "");
336 setlocale(LC_NUMERIC, "");
338 printf("%s\en", nl_langinfo(CODESET));
339 printf("%s\en", nl_langinfo(RADIXCHAR));
351 The GNU C Library Reference Manual