# locale(7) - man - phpMan

[LOCALE(7)](https://www.chedong.com/phpMan.php/man/LOCALE/7/markdown)                             Linux Programmer's Manual                            [LOCALE(7)](https://www.chedong.com/phpMan.php/man/LOCALE/7/markdown)



## NAME
       locale - description of multilanguage support

## SYNOPSIS
### #include <locale.h>

## DESCRIPTION
       A  locale  is a set of language and cultural rules.  These cover aspects such as language for
       messages, different character sets, lexicographic conventions, and so on.  A program needs to
       be able to determine its locale and act accordingly to be portable to different cultures.

       The  header  _<locale.h>_  declares  data  types, functions and macros which are useful in this
       task.

       The functions it declares are [**setlocale**(3)](https://www.chedong.com/phpMan.php/man/setlocale/3/markdown) to set the current locale,  and  [**localeconv**(3)](https://www.chedong.com/phpMan.php/man/localeconv/3/markdown)  to
       get information about number formatting.

       There are different categories for locale information a program might need; they are declared
       as macros.  Using them as the first argument to the [**setlocale**(3)](https://www.chedong.com/phpMan.php/man/setlocale/3/markdown) function, it is possible  to
       set one of these to the desired locale:

       **LC**___**ADDRESS** (GNU extension, since glibc 2.2)
              Change  settings  that  describe the formats (e.g., postal addresses) used to describe
              locations and geography-related items.  Applications that need  this  information  can
              use  **nl**___**[langinfo**(3)](https://www.chedong.com/phpMan.php/man/langinfo/3/markdown) to retrieve nonstandard elements, such as ___**NL**___**ADDRESS**___**COUNTRY**___**NAME**
              (country name, in the language of  the  locale)  and  ___**NL**___**ADDRESS**___**LANG**___**NAME**  (language
              name,  in  the language of the locale), which return strings such as "Deutschland" and
              "Deutsch" (for German-language locales).  (Other element names are  listed  in  _<lang__‐
              _info.h>_.)

       **LC**___**COLLATE**
              This  category  governs  the collation rules used for sorting and regular expressions,
              including character equivalence classes and multicharacter collating  elements.   This
              locale category changes the behavior of the functions [**strcoll**(3)](https://www.chedong.com/phpMan.php/man/strcoll/3/markdown) and [**strxfrm**(3)](https://www.chedong.com/phpMan.php/man/strxfrm/3/markdown), which
              are used to compare strings in the local alphabet.  For example, the German sharp s is
              sorted as "ss".

       **LC**___**CTYPE**
              This  category  determines  the  interpretation of byte sequences as characters (e.g.,
              single versus multibyte characters), character classifications  (e.g.,  alphabetic  or
              digit),  and  the behavior of character classes.  On glibc systems, this category also
              determines the character transliteration rules for [**iconv**(1)](https://www.chedong.com/phpMan.php/man/iconv/1/markdown) and [**iconv**(3)](https://www.chedong.com/phpMan.php/man/iconv/3/markdown).  It  changes
              the  behavior  of  the  character handling and classification functions, such as **isup**‐‐
              [**per**(3)](https://www.chedong.com/phpMan.php/man/per/3/markdown) and [**toupper**(3)](https://www.chedong.com/phpMan.php/man/toupper/3/markdown), and the multibyte character functions such as [**mblen**(3)](https://www.chedong.com/phpMan.php/man/mblen/3/markdown)  or  **wc**‐‐
              [**tomb**(3)](https://www.chedong.com/phpMan.php/man/tomb/3/markdown).

       **LC**___**IDENTIFICATION** (GNU extension, since glibc 2.2)
              Change  settings  that  relate to the metadata for the locale.  Applications that need
              this information can use **nl**___**[langinfo**(3)](https://www.chedong.com/phpMan.php/man/langinfo/3/markdown) to  retrieve  nonstandard  elements,  such  as
              ___**NL**___**IDENTIFICATION**___**TITLE** (title of this locale document) and ___**NL**___**IDENTIFICATION**___**TERRI**‐‐
              **TORY** (geographical territory to which this locale document applies), which  might  re‐
              turn strings such as "English locale for the USA" and "USA".  (Other element names are
              listed in _<langinfo.h>_.)

       **LC**___**MONETARY**
              This category determines the formatting  used  for  monetary-related  numeric  values.
              This  changes  the information returned by [**localeconv**(3)](https://www.chedong.com/phpMan.php/man/localeconv/3/markdown), which describes the way num‐
              bers are usually printed, with details such as decimal  point  versus  decimal  comma.
              This information is internally used by the function [**strfmon**(3)](https://www.chedong.com/phpMan.php/man/strfmon/3/markdown).

       **LC**___**MESSAGES**
              This  category affects the language in which messages are displayed and what an affir‐
              mative or negative answer looks like.  The GNU  C  library  contains  the  [**gettext**(3)](https://www.chedong.com/phpMan.php/man/gettext/3/markdown),
              [**ngettext**(3)](https://www.chedong.com/phpMan.php/man/ngettext/3/markdown),  and  [**rpmatch**(3)](https://www.chedong.com/phpMan.php/man/rpmatch/3/markdown)  functions to ease the use of this information.  The GNU
              gettext family of functions also obey the environment variable **LANGUAGE** (containing  a
              colon-separated  list  of locales) if the category is set to a valid locale other than
              **"C"**.  This category also affects the behavior of [**catopen**(3)](https://www.chedong.com/phpMan.php/man/catopen/3/markdown).

       **LC**___**MEASUREMENT** (GNU extension, since glibc 2.2)
              Change the settings relating to the measurement system in  the  locale  (i.e.,  metric
              versus  US customary units).  Applications can use **nl**___**[langinfo**(3)](https://www.chedong.com/phpMan.php/man/langinfo/3/markdown) to retrieve the non‐
              standard ___**NL**___**MEASUREMENT**___**MEASUREMENT** element, which returns a pointer to  a  character
              that has the value 1 (metric) or 2 (US customary units).

       **LC**___**NAME** (GNU extension, since glibc 2.2)
              Change  settings that describe the formats used to address persons.  Applications that
              need this information can use **nl**___**[langinfo**(3)](https://www.chedong.com/phpMan.php/man/langinfo/3/markdown) to retrieve nonstandard elements, such as
              ___**NL**___**NAME**___**NAME**___**MR** (general salutation for men) and ___**NL**___**NAME**___**NAME**___**MS** (general salutation
              for women) elements, which return strings such as "Herr" and "Frau"  (for  German-lan‐
              guage locales).  (Other element names are listed in _<langinfo.h>_.)

       **LC**___**NUMERIC**
              This  category determines the formatting rules used for nonmonetary numeric values—for
              example, the thousands separator and the radix character (a period  in  most  English-
              speaking  countries, but a comma in many other regions).  It affects functions such as
              [**printf**(3)](https://www.chedong.com/phpMan.php/man/printf/3/markdown), [**scanf**(3)](https://www.chedong.com/phpMan.php/man/scanf/3/markdown), and [**strtod**(3)](https://www.chedong.com/phpMan.php/man/strtod/3/markdown).  This information can also be read  with  the  **lo**‐‐
              [**caleconv**(3)](https://www.chedong.com/phpMan.php/man/caleconv/3/markdown) function.

       **LC**___**PAPER** (GNU extension, since glibc 2.2)
              Change  the  settings  relating to the dimensions of the standard paper size (e.g., US
              letter versus A4).  Applications that need the dimensions can  obtain  them  by  using
              **nl**___**[langinfo**(3)](https://www.chedong.com/phpMan.php/man/langinfo/3/markdown)  to  retrieve the nonstandard ___**NL**___**PAPER**___**WIDTH** and ___**NL**___**PAPER**___**HEIGHT** ele‐
              ments, which return _int_ values specifying the dimensions in millimeters.

       **LC**___**TELEPHONE** (GNU extension, since glibc 2.2)
              Change settings that describe the formats to be used with telephone services.   Appli‐
              cations that need this information can use **nl**___**[langinfo**(3)](https://www.chedong.com/phpMan.php/man/langinfo/3/markdown) to retrieve nonstandard ele‐
              ments, such as ___**NL**___**TELEPHONE**___**INT**___**PREFIX** (international prefix used to call numbers  in
              this locale), which returns a string such as "49" (for Germany).  (Other element names
              are listed in _<langinfo.h>_.)

       **LC**___**TIME**
              This category governs the formatting used for date and time values.  For example, most
              of  Europe  uses  a  24-hour clock versus the 12-hour clock used in the United States.
              The setting of this category affects the behavior of functions such as [**strftime**(3)](https://www.chedong.com/phpMan.php/man/strftime/3/markdown) and
              [**strptime**(3)](https://www.chedong.com/phpMan.php/man/strptime/3/markdown).

       **LC**___**ALL** All of the above.

       If  the second argument to [**setlocale**(3)](https://www.chedong.com/phpMan.php/man/setlocale/3/markdown) is an empty string, _""_, for the default locale, it is
       determined using the following steps:

       1. If there is a non-null environment variable **LC**___**ALL**, the value of **LC**___**ALL** is used.

       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.

       3. If there is a non-null environment variable **LANG**, the value of **LANG** is used.

       Values about local numeric formatting is made available in a _struct_ _lconv_ returned by the **lo**‐‐
       [**caleconv**(3)](https://www.chedong.com/phpMan.php/man/caleconv/3/markdown) function, which has the following declaration:

           struct lconv {

               /* Numeric (nonmonetary) 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;   /* International 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;
           };

### POSIX.1-2008 extensions to the locale API
       POSIX.1-2008 standardized a number of extensions to the locale API, based on  implementations
       that  first  appeared  in version 2.3 of the GNU C library.  These extensions are designed to
       address the problem that the traditional locale APIs do not mix well with  multithreaded  ap‐
       plications and with applications that must deal with multiple locales.

       The  extensions  take  the form of new functions for creating and manipulating locale objects
       ([**newlocale**(3)](https://www.chedong.com/phpMan.php/man/newlocale/3/markdown), [**freelocale**(3)](https://www.chedong.com/phpMan.php/man/freelocale/3/markdown), [**duplocale**(3)](https://www.chedong.com/phpMan.php/man/duplocale/3/markdown), and [**uselocale**(3)](https://www.chedong.com/phpMan.php/man/uselocale/3/markdown)) and various new  library  func‐
       tions  with the suffix "_l" (e.g., **toupper**___**[l**(3)](https://www.chedong.com/phpMan.php/man/l/3/markdown)) that extend the traditional locale-dependent
       APIs (e.g., [**toupper**(3)](https://www.chedong.com/phpMan.php/man/toupper/3/markdown)) to allow the specification of a locale object that should apply  when
       executing the function.

## ENVIRONMENT
       The following environment variable is used by [**newlocale**(3)](https://www.chedong.com/phpMan.php/man/newlocale/3/markdown) and [**setlocale**(3)](https://www.chedong.com/phpMan.php/man/setlocale/3/markdown), and thus affects
       all unprivileged localized programs:

       **LOCPATH**
              A list of pathnames, separated by colons (':'), that should be  used  to  find  locale
              data.   If  this  variable is set, only the individual compiled locale data files from
              **LOCPATH** and the system default locale data path are used;  any  available  locale  ar‐
              chives are not used (see [**localedef**(1)](https://www.chedong.com/phpMan.php/man/localedef/1/markdown)).  The individual compiled locale data files are
              searched for under subdirectories which depend on the currently used locale.  For  ex‐
              ample,  when  _en_GB.UTF-8_  is  used  for  a category, the following subdirectories are
              searched for, in this order: _en_GB.UTF-8_, _en_GB.utf8_, _en_GB_,  _en.UTF-8_,  _en.utf8_,  and
              _en_.

## FILES
       _/usr/lib/locale/locale-archive_
              Usual default locale archive location.

       _/usr/lib/locale_
              Usual default path for compiled individual locale files.

## CONFORMING TO
       POSIX.1-2001.

## SEE ALSO
       [**iconv**(1)](https://www.chedong.com/phpMan.php/man/iconv/1/markdown),  [**locale**(1)](https://www.chedong.com/phpMan.php/man/locale/1/markdown),  [**localedef**(1)](https://www.chedong.com/phpMan.php/man/localedef/1/markdown),  [**catopen**(3)](https://www.chedong.com/phpMan.php/man/catopen/3/markdown),  [**gettext**(3)](https://www.chedong.com/phpMan.php/man/gettext/3/markdown),  [**iconv**(3)](https://www.chedong.com/phpMan.php/man/iconv/3/markdown),  [**localeconv**(3)](https://www.chedong.com/phpMan.php/man/localeconv/3/markdown), **mb**‐‐
       [**stowcs**(3)](https://www.chedong.com/phpMan.php/man/stowcs/3/markdown), [**newlocale**(3)](https://www.chedong.com/phpMan.php/man/newlocale/3/markdown), [**ngettext**(3)](https://www.chedong.com/phpMan.php/man/ngettext/3/markdown), **nl**___**[langinfo**(3)](https://www.chedong.com/phpMan.php/man/langinfo/3/markdown), [**rpmatch**(3)](https://www.chedong.com/phpMan.php/man/rpmatch/3/markdown),  [**setlocale**(3)](https://www.chedong.com/phpMan.php/man/setlocale/3/markdown),  [**strcoll**(3)](https://www.chedong.com/phpMan.php/man/strcoll/3/markdown),
       [**strfmon**(3)](https://www.chedong.com/phpMan.php/man/strfmon/3/markdown),  [**strftime**(3)](https://www.chedong.com/phpMan.php/man/strftime/3/markdown), [**strxfrm**(3)](https://www.chedong.com/phpMan.php/man/strxfrm/3/markdown), [**uselocale**(3)](https://www.chedong.com/phpMan.php/man/uselocale/3/markdown), [**wcstombs**(3)](https://www.chedong.com/phpMan.php/man/wcstombs/3/markdown), [**locale**(5)](https://www.chedong.com/phpMan.php/man/locale/5/markdown), [**charsets**(7)](https://www.chedong.com/phpMan.php/man/charsets/7/markdown), **uni**‐‐
       [**code**(7)](https://www.chedong.com/phpMan.php/man/code/7/markdown), [**utf-8**(7)](https://www.chedong.com/phpMan.php/man/utf-8/7/markdown)

## COLOPHON
       This page is part of release 5.10 of the Linux  _man-pages_  project.   A  description  of  the
       project,  information about reporting bugs, and the latest version of this page, can be found
       at <https://www.kernel.org/doc/man-pages/>.



Linux                                        2019-03-06                                    [LOCALE(7)](https://www.chedong.com/phpMan.php/man/LOCALE/7/markdown)
