OSDN Git Service

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