1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Modified Sat Jul 24 17:28:34 1993 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified Sun Jun 01 17:16:34 1997 by Jochen Hein
28 .\" <jochen.hein@delphi.central.de>
29 .\" Modified Thu Apr 25 00:43:19 2002 by Bruno Haible <bruno@clisp.org>
31 .TH LOCALE 7 2014-05-28 "Linux" "Linux Programmer's Manual"
33 locale \- description of multilanguage support
36 .B #include <locale.h>
39 A locale is a set of language and cultural rules.
41 such as language for messages, different character sets, lexicographic
42 conventions, and so on.
43 A program needs to be able to determine its locale
44 and act accordingly to be portable to different cultures.
48 declares data types, functions and macros which are useful in this
51 The functions it declares are
53 to set the current locale, and
55 to get information about number formatting.
57 There are different categories for locale information a program might
58 need; they are declared as macros.
59 Using them as the first argument
62 function, it is possible to set one of these to the desired locale:
64 .BR LC_ADDRESS " (GNU extension, since glibc 2.2)"
65 .\" See ISO/IEC Technical Report 14652
66 Change settings that describe the formats (e.g., postal addresses)
67 used to describe locations and geography-related items.
68 Applications that need this information can use
70 to retrieve nonstandard elements, such as
71 .B _NL_ADDRESS_COUNTRY_NAME
72 (country name, in the language of the locale)
74 .B _NL_ADDRESS_LANG_NAME
75 (language name, in the language of the locale),
76 which return strings such as "Deutschland" and "Deutsch"
77 (for German-language locales).
78 (Other element names are listed in
82 This category governs the collation rules used for
83 sorting and regular expressions,
84 including character equivalence classes and
85 multicharacter collating elements.
86 This locale category changes the behavior of the functions
90 which are used to compare strings in the local alphabet.
92 the German sharp s is sorted as "ss".
95 This category determines the interpretation of byte sequences as characters
96 (e.g., single versus multibyte characters), character classifications
97 (e.g., alphabetic or digit), and the behavior of character classes.
98 It changes the behavior of the character handling and
99 classification functions, such as
103 and the multibyte character functions such as
108 .BR LC_IDENTIFICATION " (GNU extension, since glibc 2.2)"
109 .\" See ISO/IEC Technical Report 14652
110 Change settings that relate to the metadata for the locale.
111 Applications that need this information can use
113 to retrieve nonstandard elements, such as
114 .B _NL_IDENTIFICATION_TITLE
115 (title of this locale document)
117 .B _NL_IDENTIFICATION_TERRITORY
118 (geographical territory to which this locale document applies),
119 which might return strings such as "English locale for the USA"
121 (Other element names are listed in
125 This category determines the formatting used for
126 monetary-related numeric values.
127 This changes the information returned by
129 which describes the way numbers are usually printed, with details such
130 as decimal point versus decimal comma.
131 This information is internally
136 This category affects the language in which messages are displayed
137 and what an affirmative or negative answer looks like.
138 The GNU C library contains the
143 functions to ease the use of this information.
144 The GNU gettext family of
145 functions also obey the environment variable
147 (containing a colon-separated list of locales)
148 if the category is set to a valid locale other than
150 This category also affects the behavior of
153 .BR LC_MEASUREMENT " (GNU extension, since glibc 2.2)"
154 Change the settings relating to the measurement system in the locale
155 (i.e., metric versus US customary units).
158 to retrieve the nonstandard
159 .B _NL_MEASUREMENT_MEASUREMENT
160 element, which returns a pointer to a character
161 that has the value 1 (metric) or 2 (US customary units).
163 .BR LC_NAME " (GNU extension, since glibc 2.2)"
164 .\" See ISO/IEC Technical Report 14652
165 Change settings that describe the formats used to address persons.
166 Applications that need this information can use
168 to retrieve nonstandard elements, such as
170 (general salutation for men)
173 (general salutation for women)
174 elements, which return strings such as "Herr" and "Frau"
175 (for German-language locales).
176 (Other element names are listed in
180 This category determines the formatting rules used for nonmonetary
181 numeric values\(emfor example,
182 the thousands separator and the radix character
183 (a period in most English-speaking countries,
184 but a comma in many other regions).
185 It affects functions such as
190 This information can also be read with the
194 .BR LC_PAPER " (GNU extension, since glibc 2.2)"
195 .\" See ISO/IEC Technical Report 14652
196 Change the settings relating to the dimensions of the standard paper size
197 (e.g., US letter versus A4).
198 Applications that need the dimensions can obtain them by using
200 to retrieve the nonstandard
204 elements, which return
206 values specifying the dimensions in millimeters.
208 .BR LC_TELEPHONE " (GNU extension, since glibc 2.2)"
209 .\" See ISO/IEC Technical Report 14652
210 Change settings that describe the formats to be used with telephone services.
211 Applications that need this information can use
213 to retrieve nonstandard elements, such as
214 .B _NL_TELEPHONE_INT_PREFIX
215 (international prefix used to call numbers in this locale),
216 which returns a string such as "49" (for Germany).
217 (Other element names are listed in
221 This category governs the formatting used for date and time values.
222 For example, most of Europe uses a 24-hour clock versus the
223 12-hour clock used in the United States.
224 The setting of this category affects the behavior of functions such as
232 If the second argument to
236 for the default locale, it is determined using the following steps:
238 If there is a non-null environment variable
244 If an environment variable with the same name as one of the categories
245 above exists and is non-null, its value is used for that category.
247 If there is a non-null environment variable
253 Values about local numeric formatting is made available in a
257 function, which has the following declaration:
263 /* Numeric (nonmonetary) information */
265 char *decimal_point; /* Radix character */
266 char *thousands_sep; /* Separator for digit groups to left
267 of radix character */
268 char *grouping; /* Each element is the number of digits in a
269 group; elements with higher indices are
270 further left. An element with value CHAR_MAX
271 means that no further grouping is done. An
272 element with value 0 means that the previous
273 element is used for all groups further left. */
275 /* Remaining fields are for monetary information */
277 char *int_curr_symbol; /* First three chars are a currency symbol
278 from ISO 4217. Fourth char is the
279 separator. Fifth char is \(aq\\0\(aq. */
280 char *currency_symbol; /* Local currency symbol */
281 char *mon_decimal_point; /* Radix character */
282 char *mon_thousands_sep; /* Like \fIthousands_sep\fP above */
283 char *mon_grouping; /* Like \fIgrouping\fP above */
284 char *positive_sign; /* Sign for positive values */
285 char *negative_sign; /* Sign for negative values */
286 char int_frac_digits; /* International fractional digits */
287 char frac_digits; /* Local fractional digits */
288 char p_cs_precedes; /* 1 if currency_symbol precedes a
289 positive value, 0 if succeeds */
290 char p_sep_by_space; /* 1 if a space separates currency_symbol
291 from a positive value */
292 char n_cs_precedes; /* 1 if currency_symbol precedes a
293 negative value, 0 if succeeds */
294 char n_sep_by_space; /* 1 if a space separates currency_symbol
295 from a negative value */
296 /* Positive and negative sign positions:
297 0 Parentheses surround the quantity and currency_symbol.
298 1 The sign string precedes the quantity and currency_symbol.
299 2 The sign string succeeds the quantity and currency_symbol.
300 3 The sign string immediately precedes the currency_symbol.
301 4 The sign string immediately succeeds the currency_symbol. */
307 .SS POSIX.1-2008 extensions to the locale API
308 POSIX.1-2008 standardized a number of extensions to the locale API,
309 based on implementations that first appeared in version 2.3
310 of the GNU C library.
311 These extensions are designed to address the problem that
312 the traditional locale APIs do not mix well with multithreaded applications
313 and with applications that must deal with multiple locales.
315 The extensions take the form of new functions for creating and
316 manipulating locale objects
322 and various new library functions with the suffix "_l" (e.g.,
324 that extend the traditional locale-dependent APIs (e.g.,
326 to allow the specification of a locale object that should apply when
327 executing the function.
329 The following environment variable is used by
333 and thus affects all localized programs:
336 A list of pathnames, separated by colons (\(aq:\(aq),
337 that should be used to find locale data.
338 If this variable is set, only the individual locale data files from
340 and the system default locale data path are used; any available locale
341 archives are not used. The individual locale data files are searched
342 under subdirectories which depend on the currently used locale. For
345 is used for a category, the following subdirectories are searched for,
357 .\" The GNU gettext functions are specified in LI18NUX2000.