]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man/man3/nl_langinfo.3
man/, share/mk/: Move man*/ to man/
[thirdparty/man-pages.git] / man / man3 / nl_langinfo.3
CommitLineData
a1eaacb1 1'\" t
fea681da 2.\" Copyright (c) 2001 Markus Kuhn <mkuhn@acm.org>
80bf84f6
MK
3.\" and Copyright (c) 2015 Sam Varshavchik <mrsam@courier-mta.com>
4.\" and Copyright (c) 2015 Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 5.\"
e4a74ca8 6.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da
MK
7.\"
8.\" References consulted:
9.\" GNU glibc-2 manual
008f1ecc 10.\" OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
fea681da
MK
11.\"
12.\" Corrected prototype, 2002-10-18, aeb
13.\"
4c1c5274 14.TH nl_langinfo 3 (date) "Linux man-pages (unreleased)"
fea681da 15.SH NAME
665d98c5 16nl_langinfo, nl_langinfo_l \- query language and locale information
783e58cb
AC
17.SH LIBRARY
18Standard C library
8fc3b2cf 19.RI ( libc ", " \-lc )
fea681da
MK
20.SH SYNOPSIS
21.nf
22.B #include <langinfo.h>
c6d039a3 23.P
fea681da 24.BI "char *nl_langinfo(nl_item " item );
665d98c5 25.BI "char *nl_langinfo_l(nl_item " item ", locale_t " locale );
fea681da 26.fi
c6d039a3 27.P
d39ad78f 28.RS -4
4c931ba3
MK
29Feature Test Macro Requirements for glibc (see
30.BR feature_test_macros (7)):
d39ad78f 31.RE
c6d039a3 32.P
4c931ba3 33.BR nl_langinfo_l ():
9d2adbae
MK
34.nf
35 Since glibc 2.24:
5c10d2c5 36 _POSIX_C_SOURCE >= 200809L
75c018a1 37 glibc 2.23 and earlier:
5c10d2c5 38 _POSIX_C_SOURCE >= 200112L
9d2adbae 39.fi
fea681da 40.SH DESCRIPTION
60a90ecd
MK
41The
42.BR nl_langinfo ()
665d98c5
SV
43and
44.BR nl_langinfo_l ()
45functions provide access to locale information
fea681da 46in a more flexible way than
83a366e0 47.BR localeconv (3).
6614e292 48.BR nl_langinfo ()
1f741719
MK
49returns a string which is the value corresponding to
50\fIitem\fP in the program's current global
665d98c5 51locale.
5afb9373 52.BR nl_langinfo_l ()
1f741719
MK
53returns a string which is the value corresponding to \fIitem\fP
54for the locale identified by the locale object \fIlocale\fP,
83a366e0 55which was previously created by
0c9ab4fc 56.BR newlocale (3).
c13182ef 57Individual and additional elements of the locale categories can
fea681da 58be queried.
c6d039a3 59.P
fea681da 60Examples for the locale elements that can be specified in \fIitem\fP
c84371c6 61using the constants defined in \fI<langinfo.h>\fP are:
fea681da
MK
62.TP
63.BR CODESET \ (LC_CTYPE)
64Return a string with the name of the character encoding used in the
44b7300b 65selected locale, such as "UTF\-8", "ISO\-8859\-1", or "ANSI_X3.4\-1968"
c13182ef
MK
66(better known as US-ASCII).
67This is the same string that you get with
68"locale charmap".
69For a list of character encoding names,
9ab7f611
BR
70try "locale \-m" (see
71.BR locale (1)).
fea681da
MK
72.TP
73.BR D_T_FMT \ (LC_TIME)
74Return a string that can be used as a format string for
75.BR strftime (3)
6c21e49f
ES
76to represent time and date in a locale-specific way
77.RB ( %c
78conversion specification).
fea681da
MK
79.TP
80.BR D_FMT \ (LC_TIME)
81Return a string that can be used as a format string for
82.BR strftime (3)
6c21e49f
ES
83to represent a date in a locale-specific way
84.RB ( %x
85conversion specification).
fea681da
MK
86.TP
87.BR T_FMT \ (LC_TIME)
88Return a string that can be used as a format string for
89.BR strftime (3)
6c21e49f
ES
90to represent a time in a locale-specific way
91.RB ( %X
92conversion specification).
fea681da 93.TP
6602e55a
ES
94.BR AM_STR \ (LC_TIME)
95Return a string that represents affix for ante meridiem (before noon, "AM")
96time.
97(Used in
98.B %p
99.BR strftime (3)
100conversion specification.)
101.TP
102.BR PM_STR \ (LC_TIME)
103Return a string that represents affix for post meridiem (before midnight, "PM")
104time.
105(Used in
106.B %p
107.BR strftime (3)
108conversion specification.)
109.TP
110.BR T_FMT_AMPM \ (LC_TIME)
111Return a string that can be used as a format string for
112.BR strftime (3)
e6b7a7b8 113to represent a time in a.m. or p.m. notation in a locale-specific way
6602e55a
ES
114.RB ( %r
115conversion specification).
116.TP
2969f2cc 117.BR ERA \ (LC_TIME)
b18f9423 118Return era description, which contains information about how years are counted
2969f2cc
ES
119and displayed for each era in a locale.
120Each era description segment shall have the format:
121.RS
122.IP
123.IR direction : offset : start_date : end_date : era_name : era_format
124.RE
125.IP
126according to the definitions below:
127.RS
128.TP 12
129.I direction
130Either a
131.RB \[dq] + "\[dq] or a \[dq]" - \[dq]
132character.
133The
134.RB \[dq] + \[dq]
135means that years increase from the
136.I start_date
137towards the
138.IR end_date ,
139.RB \[dq] - \[dq]
140means the opposite.
141.TP
142.I offset
143The epoch year of the
144.IR start_date .
145.TP
146.I start_date
147A date in the form
148.IR yyyy / mm / dd ,
149where
150.IR yyyy ", " mm ", and " dd
151are the year, month, and day numbers respectively of the start of the era.
152.TP
153.I end_date
154The ending date of the era, in the same format as the
155.IR start_date ,
156or one of the two special values
157.RB \[dq] -* \[dq]
158(minus infinity) or
159.RB \[dq] +* \[dq]
160(plus infinity).
161.TP
162.I era_name
163The name of the era, corresponding to the
164.B %EC
165.BR strftime (3)
166conversion specification.
167.TP
168.I era_format
169The format of the year in the era, corresponding to the
170.B %EY
171.BR strftime (3)
172conversion specification.
173.RE
174.IP
175Era description segments are separated by semicolons.
176Most locales do not define this value.
b18f9423 177Examples of locales that do define this value are the Japanese and Thai
2969f2cc
ES
178locales.
179.TP
180.BR ERA_D_T_FMT \ (LC_TIME)
181Return a string that can be used as a format string for
182.BR strftime (3)
183for alternative representation of time and date in a locale-specific way
184.RB ( %Ec
185conversion specification).
186.TP
187.BR ERA_D_FMT \ (LC_TIME)
188Return a string that can be used as a format string for
189.BR strftime (3)
190for alternative representation of a date in a locale-specific way
191.RB ( %Ex
192conversion specification).
193.TP
194.BR ERA_T_FMT \ (LC_TIME)
195Return a string that can be used as a format string for
196.BR strftime (3)
197for alternative representation of a time in a locale-specific way
198.RB ( %EX
199conversion specification).
200.TP
523869f6 201.BR DAY_ "{1\[en]7} (LC_TIME)"
5e833e27
MK
202Return name of the \fIn\fP-th day of the week.
203[Warning: this follows
fea681da 204the US convention DAY_1 = Sunday, not the international convention
3f3da5b7 205(ISO\~8601) that Monday is the first day of the week.]
6c21e49f
ES
206(Used in
207.B %A
208.BR strftime (3)
209conversion specification.)
fea681da 210.TP
523869f6 211.BR ABDAY_ "{1\[en]7} (LC_TIME)"
fea681da 212Return abbreviated name of the \fIn\fP-th day of the week.
6c21e49f
ES
213(Used in
214.B %a
215.BR strftime (3)
216conversion specification.)
fea681da 217.TP
523869f6 218.BR MON_ "{1\[en]12} (LC_TIME)"
fea681da 219Return name of the \fIn\fP-th month.
6c21e49f
ES
220(Used in
221.B %B
222.BR strftime (3)
223conversion specification.)
fea681da 224.TP
523869f6 225.BR ABMON_ "{1\[en]12} (LC_TIME)"
fea681da 226Return abbreviated name of the \fIn\fP-th month.
6c21e49f
ES
227(Used in
228.B %b
229.BR strftime (3)
230conversion specification.)
fea681da
MK
231.TP
232.BR RADIXCHAR \ (LC_NUMERIC)
233Return radix character (decimal dot, decimal comma, etc.).
fea681da
MK
234.TP
235.BR THOUSEP \ (LC_NUMERIC)
236Return separator character for thousands (groups of three digits).
fea681da 237.TP
c13182ef
MK
238.BR YESEXPR \ (LC_MESSAGES)
239Return a regular expression that can be used with the
fea681da
MK
240.BR regex (3)
241function to recognize a positive response to a yes/no question.
fea681da 242.TP
c13182ef
MK
243.BR NOEXPR \ (LC_MESSAGES)
244Return a regular expression that can be used with the
fea681da
MK
245.BR regex (3)
246function to recognize a negative response to a yes/no question.
fea681da
MK
247.TP
248.BR CRNCYSTR \ (LC_MONETARY)
249Return the currency symbol, preceded by "\-" if the symbol should
250appear before the value, "+" if the symbol should appear after the
251value, or "." if the symbol should replace the radix character.
c6d039a3 252.P
c13182ef 253The above list covers just some examples of items that can be requested.
64dd3207 254For a more detailed list, consult
fea681da 255.IR "The GNU C Library Reference Manual" .
47297adb 256.SH RETURN VALUE
7003ff6a
MK
257On success, these functions return a pointer to a string which
258is the value corresponding to
259.I item
260in the specified locale.
c6d039a3 261.P
7b937140 262If no locale has been selected by
0b80cf56 263.BR setlocale (3)
7b937140 264for the appropriate category,
60a90ecd 265.BR nl_langinfo ()
29f6f82c
MK
266return a pointer to the corresponding string in the "C" locale.
267The same is true of
665d98c5 268.BR nl_langinfo_l ()
29f6f82c
MK
269if
270.I locale
271specifies a locale where
272.I langinfo
273data is not defined.
c6d039a3 274.P
fea681da 275If \fIitem\fP is not valid, a pointer to an empty string is returned.
c6d039a3 276.P
cc331dfc
MK
277The pointer returned by these functions may point to static data that
278may be overwritten, or the pointer itself may be invalidated,
279by a subsequent call to
280.BR nl_langinfo (),
281.BR nl_langinfo_l (),
60a90ecd 282or
3a72373c 283.BR setlocale (3).
cc331dfc
MK
284The same statements apply to
285.BR nl_langinfo_l ()
286if the locale object referred to by
287.I locale
288is freed or modified by
289.BR freelocale (3)
290or
291.BR newlocale (3).
c6d039a3 292.P
75b3623d
MK
293POSIX specifies that the application may not modify
294the string returned by these functions.
52aacd78
PH
295.SH ATTRIBUTES
296For an explanation of the terms used in this section, see
297.BR attributes (7).
298.TS
299allbox;
c466875e 300lbx lb lb
52aacd78
PH
301l l l.
302Interface Attribute Value
303T{
9e54434e
BR
304.na
305.nh
52aacd78
PH
306.BR nl_langinfo ()
307T} Thread safety MT-Safe locale
308.TE
3113c7f3 309.SH STANDARDS
4131356c
AC
310POSIX.1-2008.
311.SH HISTORY
312POSIX.1-2001, SUSv2.
872e754b
MK
313.SH NOTES
314The behavior of
315.BR nl_langinfo_l ()
316is undefined if
317.I locale
318is the special locale object
1ae6b2c7 319.B LC_GLOBAL_LOCALE
872e754b 320or is not a valid locale object handle.
a14af333 321.SH EXAMPLES
dbe0246b
MM
322The following program sets the character type and the numeric locale
323according to the environment and queries the terminal character set and
324the radix character.
c6d039a3 325.P
b0b6ab4e 326.\" SRC BEGIN (nl_langinfo.c)
207050fa 327.EX
7f3e079f
MH
328#include <langinfo.h>
329#include <locale.h>
330#include <stdio.h>
331#include <stdlib.h>
fe5dba13 332\&
7f3e079f 333int
7ffb8e37 334main(void)
7f3e079f 335{
68f4e1fd 336 setlocale(LC_CTYPE, "");
dbe0246b 337 setlocale(LC_NUMERIC, "");
fe5dba13 338\&
d1a71985
MK
339 printf("%s\en", nl_langinfo(CODESET));
340 printf("%s\en", nl_langinfo(RADIXCHAR));
fe5dba13 341\&
7f3e079f
MH
342 exit(EXIT_SUCCESS);
343}
207050fa 344.EE
b0b6ab4e 345.\" SRC END
47297adb 346.SH SEE ALSO
fea681da
MK
347.BR locale (1),
348.BR localeconv (3),
349.BR setlocale (3),
350.BR charsets (7),
883b0fef 351.BR locale (7)
c6d039a3 352.P
fea681da 353The GNU C Library Reference Manual