1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
.\" (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified Sat Jul 24 17:28:34 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Sun Jun 01 17:16:34 1997 by Jochen Hein
.\" <jochen.hein@delphi.central.de>
.\" Modified Thu Apr 25 00:43:19 2002 by Bruno Haible <bruno@clisp.org>
.\"
.TH LOCALE 7 1993-04-24 "Linux" "Linux Programmer's Manual"
.SH NAME
locale \- Description of multi-language support
.SH SYNOPSIS
.nf
.B #include <locale.h>
.fi
.SH DESCRIPTION
A locale is a set of language and cultural rules.
These cover aspects
such as language for messages, different character sets, lexicographic
conventions, etc.
A program needs to be able to determine its locale
and act accordingly to be portable to different cultures.
.PP
The header
.I <locale.h>
declares data types, functions and macros which are useful in this
task.
.PP
The functions it declares are
.BR setlocale (3)
to set the current locale, and
.BR localeconv (3)
to get information about number formatting.
.PP
There are different categories for local information a program might
need; they are declared as macros.
Using them as the first argument
to the
.BR setlocale (3)
function, it is possible to set one of these to the desired locale:
.TP
.B LC_COLLATE
This is used to change the behavior of the functions
.BR strcoll (3)
and
.BR strxfrm (3),
which are used to compare strings in the local alphabet.
For example,
the German sharp s is sorted as "ss".
.TP
.B LC_CTYPE
This changes the behavior of the character handling and
classification functions, such as
.BR isupper (3)
and
.BR toupper (3),
and the multi\-byte character functions such as
.BR mblen (3)
or
.BR wctomb (3).
.TP
.B LC_MONETARY
changes the information returned by
.BR localeconv (3)
which describes the way numbers are usually printed, with details such
as decimal point versus decimal comma.
This information is internally
used by the function
.BR strfmon (3).
.TP
.B LC_MESSAGES
changes the language messages are displayed in and what an affirmative or
negative answer looks like.
The GNU C-library contains the
.BR gettext (3),
.BR ngettext (3),
and
.BR rpmatch (3)
functions to ease the use of these information.
The GNU gettext family of
functions also obey the environment variable
.BR LANGUAGE .
.TP
.B LC_NUMERIC
changes the information used by the
.BR printf (3)
and
.BR scanf (3)
family of functions, when they are advised to use the locale-settings.
This information can also be read with the
.BR localeconv (3)
function.
.TP
.B LC_TIME
changes the behavior of the
.BR strftime (3)
function to display the current time in a locally acceptable form; for
example, most of Europe uses a 24\-hour clock versus the
12\-hour clock used in the United States.
.TP
.B LC_ALL
All of the above.
.\" FIXME glibc 2.2.2 added new non-standard locale categories:
.\" LC_ADDRESS, LC_IDENTIFICATION, LC_MEASUREMENT, LC_NAME,
.\" LC_PAPER, LC_TELEPHONE. These need to be documented.
.PP
If the second argument to
.BR setlocale (3)
is empty string,
.BR """""" ,
for the default locale, it is determined using the following steps:
.IP 1.
If there is a non-null environment variable
.BR LC_ALL ,
the value of
.B LC_ALL
is used.
.IP 2.
If an environment variable with the same name as one of the categories
above exists and is non-null, its value is used for that category.
.IP 3.
If there is a non-null environment variable
.BR LANG ,
the value of
.B LANG
is used.
.PP
Values about local numeric formatting is made available in a
.I struct lconv
returned by the
.BR localeconv (3)
function, which has the following declaration:
.in +0.25i
.nf
struct lconv {
/* Numeric (non-monetary) information */
char *decimal_point; /* Radix character */
char *thousands_sep; /* Separator for digit groups to left
of radix character */
char *grouping; /* Each element is the number of digits in a
group; elements with higher indices are
further left. An element with value CHAR_MAX
means that no further grouping is done. An
element with value 0 means that the previous
element is used for all groups further left. */
/* Remaining fields are for monetary information */
char *int_curr_symbol; /* First three chars are a currency symbol
from ISO 4217. Fourth char is the
separator. Fifth char is '\0'. */
char *currency_symbol; /* Local currency symbol */
char *mon_decimal_point; /* Radix character */
char *mon_thousands_sep; /* Like `thousands_sep' above */
char *mon_grouping; /* Like `grouping' above */
char *positive_sign; /* Sign for positive values */
char *negative_sign; /* Sign for negative values */
char int_frac_digits; /* Int'l fractional digits */
char frac_digits; /* Local fractional digits */
char p_cs_precedes; /* 1 if currency_symbol precedes a
positive value, 0 if succeeds */
char p_sep_by_space; /* 1 if a space separates currency_symbol
from a positive value */
char n_cs_precedes; /* 1 if currency_symbol precedes a
negative value, 0 if succeeds */
char n_sep_by_space; /* 1 if a space separates currency_symbol
from a negative value */
/* Positive and negative sign positions:
0 Parentheses surround the quantity and currency_symbol.
1 The sign string precedes the quantity and currency_symbol.
2 The sign string succeeds the quantity and currency_symbol.
3 The sign string immediately precedes the currency_symbol.
4 The sign string immediately succeeds the currency_symbol. */
char p_sign_posn;
char n_sign_posn;
};
.fi
.in +0.25i
.SH "CONFORMING TO"
POSIX.1-2001.
The GNU gettext functions are specified in LI18NUX2000.
.SH "SEE ALSO"
.BR locale (1),
.BR localedef (1),
.BR gettext (3),
.BR localeconv (3),
.BR ngettext (3),
.BR nl_langinfo (3),
.BR rpmatch (3),
.BR setlocale (3),
.BR strcoll (3),
.BR strfmon (3),
.BR strftime (3),
.BR strxfrm (3)
|