]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/nl_langinfo.3
isatty.3: Most non-tty files nowadays result in the error ENOTTY
[thirdparty/man-pages.git] / man3 / nl_langinfo.3
CommitLineData
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 20nl_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
31Feature 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
38Since glibc 2.24:
39 _POSIX_C_SOURCE\ >=\ 200809L
40.br
41Glibc 2.23 and earlier:
42 _POSIX_C_SOURCE\ >=\ 200112L
43.RE
44.ad b
fea681da 45.SH DESCRIPTION
60a90ecd
MK
46The
47.BR nl_langinfo ()
665d98c5
SV
48and
49.BR nl_langinfo_l ()
50functions provide access to locale information
fea681da 51in a more flexible way than
83a366e0 52.BR localeconv (3).
665d98c5 53.BR nl_langinfo()
1f741719
MK
54returns a string which is the value corresponding to
55\fIitem\fP in the program's current global
665d98c5
SV
56locale.
57.BR nl_langinfo()
1f741719
MK
58returns a string which is the value corresponding to \fIitem\fP
59for the locale identified by the locale object \fIlocale\fP,
83a366e0 60which was previously created by
665d98c5 61.BR newlocale (1).
c13182ef 62Individual and additional elements of the locale categories can
fea681da
MK
63be queried.
64.PP
65Examples for the locale elements that can be specified in \fIitem\fP
c84371c6 66using the constants defined in \fI<langinfo.h>\fP are:
fea681da
MK
67.TP
68.BR CODESET \ (LC_CTYPE)
69Return a string with the name of the character encoding used in the
70selected locale, such as "UTF-8", "ISO-8859-1", or "ANSI_X3.4-1968"
c13182ef
MK
71(better known as US-ASCII).
72This is the same string that you get with
73"locale charmap".
74For a list of character encoding names,
9ab7f611
BR
75try "locale \-m" (see
76.BR locale (1)).
fea681da
MK
77.TP
78.BR D_T_FMT \ (LC_TIME)
79Return a string that can be used as a format string for
80.BR strftime (3)
81to represent time and date in a locale-specific way.
fea681da
MK
82.TP
83.BR D_FMT \ (LC_TIME)
84Return a string that can be used as a format string for
85.BR strftime (3)
86to represent a date in a locale-specific way.
fea681da
MK
87.TP
88.BR T_FMT \ (LC_TIME)
89Return a string that can be used as a format string for
90.BR strftime (3)
91to represent a time in a locale-specific way.
fea681da
MK
92.TP
93.BR DAY_ "{1\(en7} (LC_TIME)"
94Return name of the \fIn\fP-th day of the week. [Warning: this follows
95the 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)"
99Return abbreviated name of the \fIn\fP-th day of the week.
fea681da
MK
100.TP
101.BR MON_ "{1\(en12} (LC_TIME)"
102Return name of the \fIn\fP-th month.
fea681da
MK
103.TP
104.BR ABMON_ "{1\(en12} (LC_TIME)"
105Return abbreviated name of the \fIn\fP-th month.
fea681da
MK
106.TP
107.BR RADIXCHAR \ (LC_NUMERIC)
108Return radix character (decimal dot, decimal comma, etc.).
fea681da
MK
109.TP
110.BR THOUSEP \ (LC_NUMERIC)
111Return separator character for thousands (groups of three digits).
fea681da 112.TP
c13182ef
MK
113.BR YESEXPR \ (LC_MESSAGES)
114Return a regular expression that can be used with the
fea681da
MK
115.BR regex (3)
116function to recognize a positive response to a yes/no question.
fea681da 117.TP
c13182ef
MK
118.BR NOEXPR \ (LC_MESSAGES)
119Return a regular expression that can be used with the
fea681da
MK
120.BR regex (3)
121function to recognize a negative response to a yes/no question.
fea681da
MK
122.TP
123.BR CRNCYSTR \ (LC_MONETARY)
124Return the currency symbol, preceded by "\-" if the symbol should
125appear before the value, "+" if the symbol should appear after the
126value, or "." if the symbol should replace the radix character.
127.PP
c13182ef 128The above list covers just some examples of items that can be requested.
64dd3207 129For a more detailed list, consult
fea681da 130.IR "The GNU C Library Reference Manual" .
47297adb 131.SH RETURN VALUE
7003ff6a
MK
132On success, these functions return a pointer to a string which
133is the value corresponding to
134.I item
135in the specified locale.
847e0d88 136.PP
7b937140 137If no locale has been selected by
0b80cf56 138.BR setlocale (3)
7b937140 139for the appropriate category,
60a90ecd 140.BR nl_langinfo ()
29f6f82c
MK
141return a pointer to the corresponding string in the "C" locale.
142The same is true of
665d98c5 143.BR nl_langinfo_l ()
29f6f82c
MK
144if
145.I locale
146specifies a locale where
147.I langinfo
148data is not defined.
fea681da
MK
149.PP
150If \fIitem\fP is not valid, a pointer to an empty string is returned.
151.PP
cc331dfc
MK
152The pointer returned by these functions may point to static data that
153may be overwritten, or the pointer itself may be invalidated,
154by a subsequent call to
155.BR nl_langinfo (),
156.BR nl_langinfo_l (),
60a90ecd 157or
3a72373c 158.BR setlocale (3).
cc331dfc
MK
159The same statements apply to
160.BR nl_langinfo_l ()
161if the locale object referred to by
162.I locale
163is freed or modified by
164.BR freelocale (3)
165or
166.BR newlocale (3).
847e0d88 167.PP
75b3623d
MK
168POSIX specifies that the application may not modify
169the string returned by these functions.
52aacd78
PH
170.SH ATTRIBUTES
171For an explanation of the terms used in this section, see
172.BR attributes (7).
173.TS
174allbox;
175lb lb lb
176l l l.
177Interface Attribute Value
178T{
179.BR nl_langinfo ()
180T} Thread safety MT-Safe locale
181.TE
47297adb 182.SH CONFORMING TO
5b36c0e4 183POSIX.1-2001, POSIX.1-2008, SUSv2.
872e754b
MK
184.SH NOTES
185The behavior of
186.BR nl_langinfo_l ()
187is undefined if
188.I locale
189is the special locale object
190.BR LC_GLOBAL_LOCALE
191or is not a valid locale object handle.
47297adb 192.SH EXAMPLE
dbe0246b
MM
193The following program sets the character type and the numeric locale
194according to the environment and queries the terminal character set and
195the 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
203int
204main(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 222The GNU C Library Reference Manual