1LOCALE(7)                  Linux Programmer's Manual                 LOCALE(7)
2
3
4

NAME

6       locale - description of multilanguage support
7

SYNOPSIS

9       #include <locale.h>
10

DESCRIPTION

12       A  locale is a set of language and cultural rules.  These cover aspects
13       such as language for messages, different character sets,  lexicographic
14       conventions,  and  so  on.  A program needs to be able to determine its
15       locale and act accordingly to be portable to different cultures.
16
17       The header <locale.h> declares data types, functions and  macros  which
18       are useful in this task.
19
20       The  functions  it declares are setlocale(3) to set the current locale,
21       and localeconv(3) to get information about number formatting.
22
23       There are different categories for locale information a  program  might
24       need; they are declared as macros.  Using them as the first argument to
25       the setlocale(3) function, it is possible to set one of  these  to  the
26       desired locale:
27
28       LC_ADDRESS (GNU extension, since glibc 2.2)
29              Change   settings   that  describe  the  formats  (e.g.,  postal
30              addresses) used  to  describe  locations  and  geography-related
31              items.  Applications that need this information can use nl_lang‐
32              info(3)   to   retrieve   nonstandard    elements,    such    as
33              _NL_ADDRESS_COUNTRY_NAME  (country  name, in the language of the
34              locale) and _NL_ADDRESS_LANG_NAME (language name,  in  the  lan‐
35              guage of the locale), which return strings such as "Deutschland"
36              and "Deutsch" (for  German-language  locales).   (Other  element
37              names are listed in <langinfo.h>.)
38
39       LC_COLLATE
40              This  category  governs the collation rules used for sorting and
41              regular expressions, including character equivalence classes and
42              multicharacter collating elements.  This locale category changes
43              the behavior of the functions strcoll(3) and  strxfrm(3),  which
44              are used to compare strings in the local alphabet.  For example,
45              the German sharp s is sorted as "ss".
46
47       LC_CTYPE
48              This category determines the interpretation of byte sequences as
49              characters (e.g., single versus multibyte characters), character
50              classifications (e.g., alphabetic or digit), and the behavior of
51              character  classes.  On glibc systems, this category also deter‐
52              mines the  character  transliteration  rules  for  iconv(1)  and
53              iconv(3).  It changes the behavior of the character handling and
54              classification functions, such as isupper(3) and toupper(3), and
55              the multibyte character functions such as mblen(3) or wctomb(3).
56
57       LC_IDENTIFICATION (GNU extension, since glibc 2.2)
58              Change  settings  that  relate  to  the metadata for the locale.
59              Applications that need this information can  use  nl_langinfo(3)
60              to   retrieve  nonstandard  elements,  such  as  _NL_IDENTIFICA‐
61              TION_TITLE (title of this locale document)  and  _NL_IDENTIFICA‐
62              TION_TERRITORY (geographical territory to which this locale doc‐
63              ument applies), which might  return  strings  such  as  "English
64              locale  for the USA" and "USA".  (Other element names are listed
65              in <langinfo.h>.)
66
67       LC_MONETARY
68              This category  determines  the  formatting  used  for  monetary-
69              related  numeric  values.  This changes the information returned
70              by localeconv(3), which describes the way  numbers  are  usually
71              printed,  with  details  such  as  decimal  point versus decimal
72              comma.  This information is  internally  used  by  the  function
73              strfmon(3).
74
75       LC_MESSAGES
76              This  category  affects  the language in which messages are dis‐
77              played and what an affirmative or negative  answer  looks  like.
78              The  GNU  C  library  contains  the gettext(3), ngettext(3), and
79              rpmatch(3) functions to ease the use of this  information.   The
80              GNU  gettext family of functions also obey the environment vari‐
81              able LANGUAGE (containing a colon-separated list of locales)  if
82              the category is set to a valid locale other than "C".  This cat‐
83              egory also affects the behavior of catopen(3).
84
85       LC_MEASUREMENT (GNU extension, since glibc 2.2)
86              Change the settings relating to the measurement  system  in  the
87              locale  (i.e.,  metric versus US customary units).  Applications
88              can use nl_langinfo(3) to retrieve the nonstandard  _NL_MEASURE‐
89              MENT_MEASUREMENT element, which returns a pointer to a character
90              that has the value 1 (metric) or 2 (US customary units).
91
92       LC_NAME (GNU extension, since glibc 2.2)
93              Change settings that describe the formats used to  address  per‐
94              sons.   Applications that need this information can use nl_lang‐
95              info(3)   to   retrieve   nonstandard    elements,    such    as
96              _NL_NAME_NAME_MR    (general    salutation    for    men)    and
97              _NL_NAME_NAME_MS (general salutation for women) elements,  which
98              return  strings  such  as "Herr" and "Frau" (for German-language
99              locales).  (Other element names are listed in <langinfo.h>.)
100
101       LC_NUMERIC
102              This category determines the formatting rules used for  nonmone‐
103              tary numeric values—for example, the thousands separator and the
104              radix character (a period in  most  English-speaking  countries,
105              but  a  comma in many other regions).  It affects functions such
106              as printf(3), scanf(3), and  strtod(3).   This  information  can
107              also be read with the localeconv(3) function.
108
109       LC_PAPER (GNU extension, since glibc 2.2)
110              Change  the  settings relating to the dimensions of the standard
111              paper size (e.g., US letter versus A4).  Applications that  need
112              the  dimensions  can  obtain  them  by  using  nl_langinfo(3) to
113              retrieve the nonstandard  _NL_PAPER_WIDTH  and  _NL_PAPER_HEIGHT
114              elements,  which  return int values specifying the dimensions in
115              millimeters.
116
117       LC_TELEPHONE (GNU extension, since glibc 2.2)
118              Change settings that describe the formats to be used with  tele‐
119              phone services.  Applications that need this information can use
120              nl_langinfo(3)  to  retrieve  nonstandard  elements,   such   as
121              _NL_TELEPHONE_INT_PREFIX (international prefix used to call num‐
122              bers in this locale), which returns a string such as  "49"  (for
123              Germany).  (Other element names are listed in <langinfo.h>.)
124
125       LC_TIME
126              This category governs the formatting used for date and time val‐
127              ues.  For example, most of Europe uses a  24-hour  clock  versus
128              the  12-hour  clock  used  in the United States.  The setting of
129              this category affects the behavior of functions  such  as  strf‐
130              time(3) and strptime(3).
131
132       LC_ALL All of the above.
133
134       If  the second argument to setlocale(3) is an empty string, "", for the
135       default locale, it is determined using the following steps:
136
137       1. If there is a non-null environment variable  LC_ALL,  the  value  of
138          LC_ALL is used.
139
140       2. If  an  environment  variable with the same name as one of the cate‐
141          gories above exists and is non-null, its value is used for that cat‐
142          egory.
143
144       3. If  there is a non-null environment variable LANG, the value of LANG
145          is used.
146
147       Values about local numeric formatting is made  available  in  a  struct
148       lconv  returned  by the localeconv(3) function, which has the following
149       declaration:
150
151           struct lconv {
152
153               /* Numeric (nonmonetary) information */
154
155               char *decimal_point;     /* Radix character */
156               char *thousands_sep;     /* Separator for digit groups to left
157                                           of radix character */
158               char *grouping;     /* Each element is the number of digits in
159                                      a group; elements with higher indices
160                                      are further left.  An element with value
161                                      CHAR_MAX means that no further grouping
162                                      is done.  An element with value 0 means
163                                      that the previous element is used for
164                                      all groups further left. */
165
166               /* Remaining fields are for monetary information */
167
168               char *int_curr_symbol;   /* First three chars are a currency
169                                           symbol from ISO 4217.  Fourth char
170                                           is the separator.  Fifth char
171                                           is '\0'. */
172               char *currency_symbol;   /* Local currency symbol */
173               char *mon_decimal_point; /* Radix character */
174               char *mon_thousands_sep; /* Like thousands_sep above */
175               char *mon_grouping;      /* Like grouping above */
176               char *positive_sign;     /* Sign for positive values */
177               char *negative_sign;     /* Sign for negative values */
178               char  int_frac_digits;   /* International fractional digits */
179               char  frac_digits;       /* Local fractional digits */
180               char  p_cs_precedes;     /* 1 if currency_symbol precedes a
181                                           positive value, 0 if succeeds */
182               char  p_sep_by_space;    /* 1 if a space separates
183                                           currency_symbol from a positive
184                                           value */
185               char  n_cs_precedes;     /* 1 if currency_symbol precedes a
186                                           negative value, 0 if succeeds */
187               char  n_sep_by_space;    /* 1 if a space separates
188                                           currency_symbol from a negative
189                                           value */
190               /* Positive and negative sign positions:
191                  0 Parentheses surround the quantity and currency_symbol.
192                  1 The sign string precedes the quantity and currency_symbol.
193                  2 The sign string succeeds the quantity and currency_symbol.
194                  3 The sign string immediately precedes the currency_symbol.
195                  4 The sign string immediately succeeds the currency_symbol. */
196               char  p_sign_posn;
197               char  n_sign_posn;
198           };
199
200   POSIX.1-2008 extensions to the locale API
201       POSIX.1-2008 standardized a number of extensions  to  the  locale  API,
202       based  on implementations that first appeared in version 2.3 of the GNU
203       C library.  These extensions are designed to address the  problem  that
204       the traditional locale APIs do not mix well with multithreaded applica‐
205       tions and with applications that must deal with multiple locales.
206
207       The extensions take the form of new functions for creating and  manipu‐
208       lating  locale  objects (newlocale(3), freelocale(3), duplocale(3), and
209       uselocale(3)) and various new library functions with  the  suffix  "_l"
210       (e.g.,  toupper_l(3)) that extend the traditional locale-dependent APIs
211       (e.g., toupper(3)) to allow the specification of a locale  object  that
212       should apply when executing the function.
213

ENVIRONMENT

215       The  following  environment variable is used by newlocale(3) and setlo‐
216       cale(3), and thus affects all unprivileged localized programs:
217
218       LOCPATH
219              A list of pathnames, separated by colons (':'), that  should  be
220              used  to  find  locale  data.  If this variable is set, only the
221              individual compiled locale data files from LOCPATH and the  sys‐
222              tem  default locale data path are used; any available locale ar‐
223              chives are not used (see localedef(1)).  The individual compiled
224              locale  data  files  are searched for under subdirectories which
225              depend  on  the  currently  used  locale.   For  example,   when
226              en_GB.UTF-8 is used for a category, the following subdirectories
227              are searched for, in this order: en_GB.UTF-8, en_GB.utf8, en_GB,
228              en.UTF-8, en.utf8, and en.
229

FILES

231       /usr/lib/locale/locale-archive
232              Usual default locale archive location.
233
234       /usr/lib/locale
235              Usual default path for compiled individual locale files.
236

CONFORMING TO

238       POSIX.1-2001.
239

SEE ALSO

241       iconv(1),  locale(1),  localedef(1),  catopen(3), gettext(3), iconv(3),
242       localeconv(3), mbstowcs(3), newlocale(3), ngettext(3),  nl_langinfo(3),
243       rpmatch(3),    setlocale(3),   strcoll(3),   strfmon(3),   strftime(3),
244       strxfrm(3), uselocale(3),  wcstombs(3),  locale(5),  charsets(7),  uni‐
245       code(7), utf-8(7)
246

COLOPHON

248       This  page  is  part of release 5.04 of the Linux man-pages project.  A
249       description of the project, information about reporting bugs,  and  the
250       latest     version     of     this    page,    can    be    found    at
251       https://www.kernel.org/doc/man-pages/.
252
253
254
255Linux                             2019-03-06                         LOCALE(7)
Impressum