]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/locale.7
man*/: srcfix
[thirdparty/man-pages.git] / man7 / locale.7
CommitLineData
bf5a7247 1.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
7c57cb80 2.\" and Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
fea681da 3.\"
5fbde956 4.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da
MK
5.\"
6.\" Modified Sat Jul 24 17:28:34 1993 by Rik Faith <faith@cs.unc.edu>
7.\" Modified Sun Jun 01 17:16:34 1997 by Jochen Hein
8.\" <jochen.hein@delphi.central.de>
9.\" Modified Thu Apr 25 00:43:19 2002 by Bruno Haible <bruno@clisp.org>
10.\"
4c1c5274 11.TH locale 7 (date) "Linux man-pages (unreleased)"
fea681da 12.SH NAME
f68512e9 13locale \- description of multilanguage support
fea681da
MK
14.SH SYNOPSIS
15.nf
16.B #include <locale.h>
17.fi
18.SH DESCRIPTION
c13182ef
MK
19A locale is a set of language and cultural rules.
20These cover aspects
3f1c1b0a 21such as language for messages, different character sets, lexicographic
004e0245 22conventions, and so on.
c13182ef 23A program needs to be able to determine its locale
fea681da 24and act accordingly to be portable to different cultures.
c6d039a3 25.P
fea681da 26The header
bd12ab88 27.I <locale.h>
735334d4 28declares data types, functions, and macros which are useful in this
fea681da 29task.
c6d039a3 30.P
fea681da 31The functions it declares are
63f6a20a 32.BR setlocale (3)
fea681da 33to set the current locale, and
63f6a20a 34.BR localeconv (3)
fea681da 35to get information about number formatting.
c6d039a3 36.P
8d63e6ec 37There are different categories for locale information a program might
c13182ef
MK
38need; they are declared as macros.
39Using them as the first argument
fea681da 40to the
63f6a20a 41.BR setlocale (3)
fea681da
MK
42function, it is possible to set one of these to the desired locale:
43.TP
798f7baf 44.BR LC_ADDRESS " (GNU extension, since glibc 2.2)"
de0f9c1c 45.\" See ISO/IEC Technical Report 14652
798f7baf
MK
46Change settings that describe the formats (e.g., postal addresses)
47used to describe locations and geography-related items.
48Applications that need this information can use
49.BR nl_langinfo (3)
50to retrieve nonstandard elements, such as
51.B _NL_ADDRESS_COUNTRY_NAME
52(country name, in the language of the locale)
53and
54.B _NL_ADDRESS_LANG_NAME
ebb55337
MK
55(language name, in the language of the locale),
56which return strings such as "Deutschland" and "Deutsch"
798f7baf
MK
57(for German-language locales).
58(Other element names are listed in
59.IR <langinfo.h> .)
60.TP
fea681da 61.B LC_COLLATE
d099bdc5
MK
62This category governs the collation rules used for
63sorting and regular expressions,
64including character equivalence classes and
65multicharacter collating elements.
66This locale category changes the behavior of the functions
63f6a20a 67.BR strcoll (3)
fea681da 68and
63f6a20a 69.BR strxfrm (3),
c13182ef
MK
70which are used to compare strings in the local alphabet.
71For example,
fea681da
MK
72the German sharp s is sorted as "ss".
73.TP
74.B LC_CTYPE
d099bdc5
MK
75This category determines the interpretation of byte sequences as characters
76(e.g., single versus multibyte characters), character classifications
77(e.g., alphabetic or digit), and the behavior of character classes.
c42df710
MK
78On glibc systems, this category also determines
79the character transliteration rules for
3d6d6fac
MM
80.BR iconv (1)
81and
82.BR iconv (3).
d099bdc5 83It changes the behavior of the character handling and
fea681da 84classification functions, such as
63f6a20a 85.BR isupper (3)
fea681da 86and
63f6a20a 87.BR toupper (3),
ae03dc66 88and the multibyte character functions such as
63f6a20a 89.BR mblen (3)
fea681da 90or
63f6a20a 91.BR wctomb (3).
fea681da 92.TP
5f49682e 93.BR LC_IDENTIFICATION " (GNU extension, since glibc 2.2)"
de0f9c1c 94.\" See ISO/IEC Technical Report 14652
f360dbe8 95Change settings that relate to the metadata for the locale.
5f49682e
MK
96Applications that need this information can use
97.BR nl_langinfo (3)
98to retrieve nonstandard elements, such as
99.B _NL_IDENTIFICATION_TITLE
100(title of this locale document)
101and
102.B _NL_IDENTIFICATION_TERRITORY
f360dbe8 103(geographical territory to which this locale document applies),
5f49682e
MK
104which might return strings such as "English locale for the USA"
105and "USA".
106(Other element names are listed in
107.IR <langinfo.h> .)
108.TP
fea681da 109.B LC_MONETARY
d099bdc5
MK
110This category determines the formatting used for
111monetary-related numeric values.
fb844405 112This changes the information returned by
d099bdc5 113.BR localeconv (3),
fea681da 114which describes the way numbers are usually printed, with details such
c13182ef
MK
115as decimal point versus decimal comma.
116This information is internally
fea681da 117used by the function
63f6a20a 118.BR strfmon (3).
fea681da
MK
119.TP
120.B LC_MESSAGES
d099bdc5
MK
121This category affects the language in which messages are displayed
122and what an affirmative or negative answer looks like.
0eb0bdd2 123The GNU C library contains the
63f6a20a
MK
124.BR gettext (3),
125.BR ngettext (3),
fea681da 126and
63f6a20a 127.BR rpmatch (3)
a33c5137 128functions to ease the use of this information.
c13182ef 129The GNU gettext family of
fea681da 130functions also obey the environment variable
1ae6b2c7 131.B LANGUAGE
97aec57c
MK
132(containing a colon-separated list of locales)
133if the category is set to a valid locale other than
c40c1a54 134.BR \[dq]C\[dq] .
d099bdc5
MK
135This category also affects the behavior of
136.BR catopen (3).
fea681da 137.TP
7c57cb80
MK
138.BR LC_MEASUREMENT " (GNU extension, since glibc 2.2)"
139Change the settings relating to the measurement system in the locale
140(i.e., metric versus US customary units).
141Applications can use
142.BR nl_langinfo (3)
143to retrieve the nonstandard
144.B _NL_MEASUREMENT_MEASUREMENT
145element, which returns a pointer to a character
146that has the value 1 (metric) or 2 (US customary units).
147.TP
ba5e9ef3 148.BR LC_NAME " (GNU extension, since glibc 2.2)"
de0f9c1c 149.\" See ISO/IEC Technical Report 14652
ba5e9ef3
MK
150Change settings that describe the formats used to address persons.
151Applications that need this information can use
152.BR nl_langinfo (3)
153to retrieve nonstandard elements, such as
154.B _NL_NAME_NAME_MR
155(general salutation for men)
156and
157.B _NL_NAME_NAME_MS
158(general salutation for women)
159elements, which return strings such as "Herr" and "Frau"
160(for German-language locales).
161(Other element names are listed in
162.IR <langinfo.h> .)
163.TP
fea681da 164.B LC_NUMERIC
d099bdc5 165This category determines the formatting rules used for nonmonetary
36546c38 166numeric values\[em]for example,
d099bdc5
MK
167the thousands separator and the radix character
168(a period in most English-speaking countries,
169but a comma in many other regions).
170It affects functions such as
6cecebf1 171.BR printf (3),
d099bdc5 172.BR scanf (3),
fea681da 173and
d099bdc5 174.BR strtod (3).
c13182ef 175This information can also be read with the
63f6a20a 176.BR localeconv (3)
fea681da
MK
177function.
178.TP
0b65297e 179.BR LC_PAPER " (GNU extension, since glibc 2.2)"
de0f9c1c 180.\" See ISO/IEC Technical Report 14652
0b65297e
MK
181Change the settings relating to the dimensions of the standard paper size
182(e.g., US letter versus A4).
183Applications that need the dimensions can obtain them by using
184.BR nl_langinfo (3)
185to retrieve the nonstandard
186.B _NL_PAPER_WIDTH
187and
188.B _NL_PAPER_HEIGHT
189elements, which return
190.I int
191values specifying the dimensions in millimeters.
192.TP
1c598039 193.BR LC_TELEPHONE " (GNU extension, since glibc 2.2)"
de0f9c1c 194.\" See ISO/IEC Technical Report 14652
1c598039
MK
195Change settings that describe the formats to be used with telephone services.
196Applications that need this information can use
197.BR nl_langinfo (3)
198to retrieve nonstandard elements, such as
199.B _NL_TELEPHONE_INT_PREFIX
200(international prefix used to call numbers in this locale),
201which returns a string such as "49" (for Germany).
202(Other element names are listed in
203.IR <langinfo.h> .)
204.TP
fea681da 205.B LC_TIME
d099bdc5
MK
206This category governs the formatting used for date and time values.
207For example, most of Europe uses a 24-hour clock versus the
2706f299 20812-hour clock used in the United States.
b5450631 209The setting of this category affects the behavior of functions such as
d099bdc5
MK
210.BR strftime (3)
211and
212.BR strptime (3).
fea681da
MK
213.TP
214.B LC_ALL
215All of the above.
c6d039a3 216.P
fea681da 217If the second argument to
63f6a20a 218.BR setlocale (3)
47e067e5 219is an empty string,
9c708002 220.IR \[dq]\[dq] ,
fea681da 221for the default locale, it is determined using the following steps:
22356d97 222.IP (1) 5
fea681da
MK
223If there is a non-null environment variable
224.BR LC_ALL ,
225the value of
226.B LC_ALL
227is used.
22356d97 228.IP (2)
fea681da
MK
229If an environment variable with the same name as one of the categories
230above exists and is non-null, its value is used for that category.
22356d97 231.IP (3)
fea681da
MK
232If there is a non-null environment variable
233.BR LANG ,
234the value of
235.B LANG
236is used.
c6d039a3 237.P
fea681da 238Values about local numeric formatting is made available in a
8478ee02 239.I struct lconv
fea681da 240returned by the
63f6a20a 241.BR localeconv (3)
fea681da 242function, which has the following declaration:
c6d039a3 243.P
9c40f2b9
MK
244.in +4n
245.EX
f6fa37d1 246struct lconv {
fe5dba13 247\&
b4b78977 248 /* Numeric (nonmonetary) information */
fe5dba13 249\&
088a639b
MK
250 char *decimal_point; /* Radix character */
251 char *thousands_sep; /* Separator for digit groups to left
252 of radix character */
3cf30efc
MK
253 char *grouping; /* Each element is the number of digits in
254 a group; elements with higher indices
255 are further left. An element with value
256 CHAR_MAX means that no further grouping
257 is done. An element with value 0 means
258 that the previous element is used for
259 all groups further left. */
fe5dba13 260\&
088a639b 261 /* Remaining fields are for monetary information */
fe5dba13 262\&
3cf30efc
MK
263 char *int_curr_symbol; /* First three chars are a currency
264 symbol from ISO 4217. Fourth char
265 is the separator. Fifth char
b957f81f 266 is \[aq]\e0\[aq]. */
088a639b
MK
267 char *currency_symbol; /* Local currency symbol */
268 char *mon_decimal_point; /* Radix character */
269 char *mon_thousands_sep; /* Like \fIthousands_sep\fP above */
270 char *mon_grouping; /* Like \fIgrouping\fP above */
271 char *positive_sign; /* Sign for positive values */
272 char *negative_sign; /* Sign for negative values */
84c517a4 273 char int_frac_digits; /* International fractional digits */
088a639b
MK
274 char frac_digits; /* Local fractional digits */
275 char p_cs_precedes; /* 1 if currency_symbol precedes a
276 positive value, 0 if succeeds */
3cf30efc
MK
277 char p_sep_by_space; /* 1 if a space separates
278 currency_symbol from a positive
279 value */
088a639b
MK
280 char n_cs_precedes; /* 1 if currency_symbol precedes a
281 negative value, 0 if succeeds */
3cf30efc
MK
282 char n_sep_by_space; /* 1 if a space separates
283 currency_symbol from a negative
284 value */
088a639b
MK
285 /* Positive and negative sign positions:
286 0 Parentheses surround the quantity and currency_symbol.
287 1 The sign string precedes the quantity and currency_symbol.
288 2 The sign string succeeds the quantity and currency_symbol.
289 3 The sign string immediately precedes the currency_symbol.
290 4 The sign string immediately succeeds the currency_symbol. */
291 char p_sign_posn;
292 char n_sign_posn;
fea681da 293};
b8302363 294.EE
088a639b 295.in
4aeed369
MK
296.SS POSIX.1-2008 extensions to the locale API
297POSIX.1-2008 standardized a number of extensions to the locale API,
b324e17d 298based on implementations that first appeared in glibc 2.3.
89851a00 299These extensions are designed to address the problem that
2fa99a62 300the traditional locale APIs do not mix well with multithreaded applications
4aeed369 301and with applications that must deal with multiple locales.
c6d039a3 302.P
4aeed369
MK
303The extensions take the form of new functions for creating and
304manipulating locale objects
305.RB ( newlocale (3),
306.BR freelocale (3),
307.BR duplocale (3),
308and
309.BR uselocale (3))
310and various new library functions with the suffix "_l" (e.g.,
311.BR toupper_l (3))
312that extend the traditional locale-dependent APIs (e.g.,
313.BR toupper (3))
314to allow the specification of a locale object that should apply when
315executing the function.
cd2b4f6e 316.SH ENVIRONMENT
b331e0d0
MK
317The following environment variable is used by
318.BR newlocale (3)
319and
320.BR setlocale (3),
c5466970 321and thus affects all unprivileged localized programs:
cd2b4f6e
MM
322.TP
323.B LOCPATH
b957f81f 324A list of pathnames, separated by colons (\[aq]:\[aq]),
9fb49a3a 325that should be used to find locale data.
476cab32
MK
326If this variable is set,
327only the individual compiled locale data files from
a6c67952 328.B LOCPATH
c5466970
MM
329and the system default locale data path are used;
330any available locale archives are not used (see
331.BR localedef (1)).
476cab32 332The individual compiled locale data files are searched for under
c5466970
MM
333subdirectories which depend on the currently used locale.
334For example, when
cd415e73 335.I en_GB.UTF\-8
859476f7
MM
336is used for a category, the following subdirectories are searched for,
337in this order:
cd415e73 338.IR en_GB.UTF\-8 ,
859476f7
MM
339.IR en_GB.utf8 ,
340.IR en_GB ,
cd415e73 341.IR en.UTF\-8 ,
859476f7
MM
342.IR en.utf8 ,
343and
344.IR en .
c5466970
MM
345.SH FILES
346.TP
b49c2acb 347.I /usr/lib/locale/locale\-archive
c5466970
MM
348Usual default locale archive location.
349.TP
350.I /usr/lib/locale
351Usual default path for compiled individual locale files.
3113c7f3 352.SH STANDARDS
a7fadb55 353POSIX.1-2001.
89851a00 354.\"
2fa99a62 355.\" The GNU gettext functions are specified in LI18NUX2000.
47297adb 356.SH SEE ALSO
3d6d6fac 357.BR iconv (1),
fea681da
MK
358.BR locale (1),
359.BR localedef (1),
5be6f51f 360.BR catopen (3),
fea681da 361.BR gettext (3),
3d6d6fac 362.BR iconv (3),
fea681da 363.BR localeconv (3),
713167dc 364.BR mbstowcs (3),
a8de62de 365.BR newlocale (3),
fea681da
MK
366.BR ngettext (3),
367.BR nl_langinfo (3),
368.BR rpmatch (3),
369.BR setlocale (3),
370.BR strcoll (3),
371.BR strfmon (3),
372.BR strftime (3),
6985a63a 373.BR strxfrm (3),
a8de62de 374.BR uselocale (3),
713167dc 375.BR wcstombs (3),
66aa7615
MM
376.BR locale (5),
377.BR charsets (7),
378.BR unicode (7),
28a4c58c 379.BR utf\-8 (7)