OSDN Git Service

LDP: Update original to LDP v3.68
[linuxjm/LDP_man-pages.git] / original / man3 / nl_langinfo.3
1 .\" Copyright (c) 2001 Markus Kuhn <mkuhn@acm.org>
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_ONEPARA)
4 .\" This is free documentation; you can redistribute it and/or
5 .\" modify it under the terms of the GNU General Public License as
6 .\" published by the Free Software Foundation; either version 2 of
7 .\" the License, or (at your option) any later version.
8 .\" %%%LICENSE_END
9 .\"
10 .\" References consulted:
11 .\"   GNU glibc-2 manual
12 .\"   OpenGroup's Single UNIX specification http://www.UNIX-systems.org/online.html
13 .\"
14 .\" Corrected prototype, 2002-10-18, aeb
15 .\"
16 .TH NL_LANGINFO 3  2014-05-28 "GNU" "Linux Programmer's Manual"
17 .SH NAME
18 nl_langinfo \- query language and locale information
19 .SH SYNOPSIS
20 .nf
21 .B #include <langinfo.h>
22 .sp
23 .BI "char *nl_langinfo(nl_item " item );
24 .fi
25 .SH DESCRIPTION
26 The
27 .BR nl_langinfo ()
28 function provides access to locale information
29 in a more flexible way than
30 .BR localeconv (3)
31 does.
32 Individual and additional elements of the locale categories can
33 be queried.
34 .PP
35 Examples for the locale elements that can be specified in \fIitem\fP
36 using the constants defined in \fI<langinfo.h>\fP are:
37 .TP
38 .BR CODESET \ (LC_CTYPE)
39 Return a string with the name of the character encoding used in the
40 selected locale, such as "UTF-8", "ISO-8859-1", or "ANSI_X3.4-1968"
41 (better known as US-ASCII).
42 This is the same string that you get with
43 "locale charmap".
44 For a list of character encoding names,
45 try "locale \-m", cf.\&
46 .BR locale (1).
47 .TP
48 .BR D_T_FMT \ (LC_TIME)
49 Return a string that can be used as a format string for
50 .BR strftime (3)
51 to represent time and date in a locale-specific way.
52 .TP
53 .BR D_FMT \ (LC_TIME)
54 Return a string that can be used as a format string for
55 .BR strftime (3)
56 to represent a date in a locale-specific way.
57 .TP
58 .BR T_FMT \ (LC_TIME)
59 Return a string that can be used as a format string for
60 .BR strftime (3)
61 to represent a time in a locale-specific way.
62 .TP
63 .BR DAY_ "{1\(en7} (LC_TIME)"
64 Return name of the \fIn\fP-th day of the week. [Warning: this follows
65 the US convention DAY_1 = Sunday, not the international convention
66 (ISO 8601) that Monday is the first day of the week.]
67 .TP
68 .BR ABDAY_ "{1\(en7} (LC_TIME)"
69 Return abbreviated name of the \fIn\fP-th day of the week.
70 .TP
71 .BR MON_ "{1\(en12} (LC_TIME)"
72 Return name of the \fIn\fP-th month.
73 .TP
74 .BR ABMON_ "{1\(en12} (LC_TIME)"
75 Return abbreviated name of the \fIn\fP-th month.
76 .TP
77 .BR RADIXCHAR \ (LC_NUMERIC)
78 Return radix character (decimal dot, decimal comma, etc.).
79 .TP
80 .BR THOUSEP \ (LC_NUMERIC)
81 Return separator character for thousands (groups of three digits).
82 .TP
83 .BR YESEXPR \ (LC_MESSAGES)
84 Return a regular expression that can be used with the
85 .BR regex (3)
86 function to recognize a positive response to a yes/no question.
87 .TP
88 .BR NOEXPR \ (LC_MESSAGES)
89 Return a regular expression that can be used with the
90 .BR regex (3)
91 function to recognize a negative response to a yes/no question.
92 .TP
93 .BR CRNCYSTR \ (LC_MONETARY)
94 Return the currency symbol, preceded by "\-" if the symbol should
95 appear before the value, "+" if the symbol should appear after the
96 value, or "." if the symbol should replace the radix character.
97 .PP
98 The above list covers just some examples of items that can be requested.
99 For a more detailed list, consult
100 .IR "The GNU C Library Reference Manual" .
101 .SH RETURN VALUE
102 If no locale has been selected by
103 .BR setlocale (3)
104 for the appropriate category,
105 .BR nl_langinfo ()
106 returns a pointer to the corresponding string in the
107 "C" locale.
108 .PP
109 If \fIitem\fP is not valid, a pointer to an empty string is returned.
110 .PP
111 This pointer may point to static data that may be overwritten on the
112 next call to
113 .BR nl_langinfo ()
114 or
115 .BR setlocale (3).
116 .SH CONFORMING TO
117 SUSv2, POSIX.1-2001.
118 .SH EXAMPLE
119 The following program sets the character type and the numeric locale
120 according to the environment and queries the terminal character set and
121 the radix character.
122 .LP
123 .nf
124 #include <langinfo.h>
125 #include <locale.h>
126 #include <stdio.h>
127 #include <stdlib.h>
128
129 int
130 main(int argc, char *argv[])
131 {
132     setlocale(LC_CTYPE, "");
133     setlocale(LC_NUMERIC, "");
134     printf("%s\\n", nl_langinfo(CODESET));
135     printf("%s\\n", nl_langinfo(RADIXCHAR));
136     exit(EXIT_SUCCESS);
137 }
138 .fi
139 .SH SEE ALSO
140 .BR locale (1),
141 .BR localeconv (3),
142 .BR setlocale (3),
143 .BR charsets (7),
144 .BR locale (7)
145 .br
146 The GNU C Library Reference Manual
147 .SH COLOPHON
148 This page is part of release 3.68 of the Linux
149 .I man-pages
150 project.
151 A description of the project,
152 information about reporting bugs,
153 and the latest version of this page,
154 can be found at
155 \%http://www.kernel.org/doc/man\-pages/.