557 lines
21 KiB
HTML
557 lines
21 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of LOCALE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>LOCALE</H1>
|
|
Section: Linux Programmer's Manual (7)<BR>Updated: 2019-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
locale - description of multilanguage support
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<PRE>
|
|
<B>#include <<A HREF="file:///usr/include/locale.h">locale.h</A>></B>
|
|
</PRE>
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
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.
|
|
<P>
|
|
|
|
The header
|
|
<I><<A HREF="file:///usr/include/locale.h">locale.h</A>></I>
|
|
|
|
declares data types, functions and macros which are useful in this
|
|
task.
|
|
<P>
|
|
|
|
The functions it declares are
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3)
|
|
|
|
to set the current locale, and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+localeconv">localeconv</A></B>(3)
|
|
|
|
to get information about number formatting.
|
|
<P>
|
|
|
|
There are different categories for locale information a program might
|
|
need; they are declared as macros.
|
|
Using them as the first argument
|
|
to the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3)
|
|
|
|
function, it is possible to set one of these to the desired locale:
|
|
<DL COMPACT>
|
|
<DT id="1"><B>LC_ADDRESS</B> (GNU extension, since glibc 2.2)
|
|
|
|
<DD>
|
|
|
|
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
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3)
|
|
|
|
to retrieve nonstandard elements, such as
|
|
<B>_NL_ADDRESS_COUNTRY_NAME</B>
|
|
|
|
(country name, in the language of the locale)
|
|
and
|
|
<B>_NL_ADDRESS_LANG_NAME</B>
|
|
|
|
(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
|
|
<I><<A HREF="file:///usr/include/langinfo.h">langinfo.h</A>></I>.)
|
|
|
|
<DT id="2"><B>LC_COLLATE</B>
|
|
|
|
<DD>
|
|
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
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcoll">strcoll</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strxfrm">strxfrm</A></B>(3),
|
|
|
|
which are used to compare strings in the local alphabet.
|
|
For example,
|
|
the German sharp s is sorted as "ss".
|
|
<DT id="3"><B>LC_CTYPE</B>
|
|
|
|
<DD>
|
|
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
|
|
<B><A HREF="/cgi-bin/man/man2html?1+iconv">iconv</A></B>(1)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+iconv">iconv</A></B>(3).
|
|
|
|
It changes the behavior of the character handling and
|
|
classification functions, such as
|
|
<B><A HREF="/cgi-bin/man/man2html?3+isupper">isupper</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+toupper">toupper</A></B>(3),
|
|
|
|
and the multibyte character functions such as
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mblen">mblen</A></B>(3)
|
|
|
|
or
|
|
<B><A HREF="/cgi-bin/man/man2html?3+wctomb">wctomb</A></B>(3).
|
|
|
|
<DT id="4"><B>LC_IDENTIFICATION</B> (GNU extension, since glibc 2.2)
|
|
|
|
<DD>
|
|
|
|
Change settings that relate to the metadata for the locale.
|
|
Applications that need this information can use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3)
|
|
|
|
to retrieve nonstandard elements, such as
|
|
<B>_NL_IDENTIFICATION_TITLE</B>
|
|
|
|
(title of this locale document)
|
|
and
|
|
<B>_NL_IDENTIFICATION_TERRITORY</B>
|
|
|
|
(geographical territory to which this locale document applies),
|
|
which might return strings such as "English locale for the USA"
|
|
and "USA".
|
|
(Other element names are listed in
|
|
<I><<A HREF="file:///usr/include/langinfo.h">langinfo.h</A>></I>.)
|
|
|
|
<DT id="5"><B>LC_MONETARY</B>
|
|
|
|
<DD>
|
|
This category determines the formatting used for
|
|
monetary-related numeric values.
|
|
This changes the information returned by
|
|
<B><A HREF="/cgi-bin/man/man2html?3+localeconv">localeconv</A></B>(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
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strfmon">strfmon</A></B>(3).
|
|
|
|
<DT id="6"><B>LC_MESSAGES</B>
|
|
|
|
<DD>
|
|
This category affects the language in which messages are displayed
|
|
and what an affirmative or negative answer looks like.
|
|
The GNU C library contains the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+gettext">gettext</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ngettext">ngettext</A></B>(3),
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+rpmatch">rpmatch</A></B>(3)
|
|
|
|
functions to ease the use of this information.
|
|
The GNU gettext family of
|
|
functions also obey the environment variable
|
|
<B>LANGUAGE</B>
|
|
|
|
(containing a colon-separated list of locales)
|
|
if the category is set to a valid locale other than
|
|
<B>"C"</B>.
|
|
|
|
This category also affects the behavior of
|
|
<B><A HREF="/cgi-bin/man/man2html?3+catopen">catopen</A></B>(3).
|
|
|
|
<DT id="7"><B>LC_MEASUREMENT</B> (GNU extension, since glibc 2.2)
|
|
|
|
<DD>
|
|
Change the settings relating to the measurement system in the locale
|
|
(i.e., metric versus US customary units).
|
|
Applications can use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3)
|
|
|
|
to retrieve the nonstandard
|
|
<B>_NL_MEASUREMENT_MEASUREMENT</B>
|
|
|
|
element, which returns a pointer to a character
|
|
that has the value 1 (metric) or 2 (US customary units).
|
|
<DT id="8"><B>LC_NAME</B> (GNU extension, since glibc 2.2)
|
|
|
|
<DD>
|
|
|
|
Change settings that describe the formats used to address persons.
|
|
Applications that need this information can use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3)
|
|
|
|
to retrieve nonstandard elements, such as
|
|
<B>_NL_NAME_NAME_MR</B>
|
|
|
|
(general salutation for men)
|
|
and
|
|
<B>_NL_NAME_NAME_MS</B>
|
|
|
|
(general salutation for women)
|
|
elements, which return strings such as "Herr" and "Frau"
|
|
(for German-language locales).
|
|
(Other element names are listed in
|
|
<I><<A HREF="file:///usr/include/langinfo.h">langinfo.h</A>></I>.)
|
|
|
|
<DT id="9"><B>LC_NUMERIC</B>
|
|
|
|
<DD>
|
|
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
|
|
<B><A HREF="/cgi-bin/man/man2html?3+printf">printf</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+scanf">scanf</A></B>(3),
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strtod">strtod</A></B>(3).
|
|
|
|
This information can also be read with the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+localeconv">localeconv</A></B>(3)
|
|
|
|
function.
|
|
<DT id="10"><B>LC_PAPER</B> (GNU extension, since glibc 2.2)
|
|
|
|
<DD>
|
|
|
|
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
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3)
|
|
|
|
to retrieve the nonstandard
|
|
<B>_NL_PAPER_WIDTH</B>
|
|
|
|
and
|
|
<B>_NL_PAPER_HEIGHT</B>
|
|
|
|
elements, which return
|
|
<I>int</I>
|
|
|
|
values specifying the dimensions in millimeters.
|
|
<DT id="11"><B>LC_TELEPHONE</B> (GNU extension, since glibc 2.2)
|
|
|
|
<DD>
|
|
|
|
Change settings that describe the formats to be used with telephone services.
|
|
Applications that need this information can use
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3)
|
|
|
|
to retrieve nonstandard elements, such as
|
|
<B>_NL_TELEPHONE_INT_PREFIX</B>
|
|
|
|
(international prefix used to call numbers in this locale),
|
|
which returns a string such as "49" (for Germany).
|
|
(Other element names are listed in
|
|
<I><<A HREF="file:///usr/include/langinfo.h">langinfo.h</A>></I>.)
|
|
|
|
<DT id="12"><B>LC_TIME</B>
|
|
|
|
<DD>
|
|
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
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strftime">strftime</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strptime">strptime</A></B>(3).
|
|
|
|
<DT id="13"><B>LC_ALL</B>
|
|
|
|
<DD>
|
|
All of the above.
|
|
</DL>
|
|
<P>
|
|
|
|
If the second argument to
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3)
|
|
|
|
is an empty string,
|
|
<I>""</I>,
|
|
|
|
for the default locale, it is determined using the following steps:
|
|
<DL COMPACT>
|
|
<DT id="14">1.<DD>
|
|
If there is a non-null environment variable
|
|
<B>LC_ALL</B>,
|
|
|
|
the value of
|
|
<B>LC_ALL</B>
|
|
|
|
is used.
|
|
<DT id="15">2.<DD>
|
|
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.
|
|
<DT id="16">3.<DD>
|
|
If there is a non-null environment variable
|
|
<B>LANG</B>,
|
|
|
|
the value of
|
|
<B>LANG</B>
|
|
|
|
is used.
|
|
</DL>
|
|
<P>
|
|
|
|
Values about local numeric formatting is made available in a
|
|
<I>struct lconv</I>
|
|
|
|
returned by the
|
|
<B><A HREF="/cgi-bin/man/man2html?3+localeconv">localeconv</A></B>(3)
|
|
|
|
function, which has the following declaration:
|
|
<P>
|
|
|
|
|
|
|
|
struct lconv {
|
|
<P>
|
|
<BR> /* Numeric (nonmonetary) information */
|
|
<P>
|
|
<BR> char *decimal_point; /* Radix character */
|
|
<BR> char *thousands_sep; /* Separator for digit groups to left
|
|
<BR> of radix character */
|
|
<BR> char *grouping; /* Each element is the number of digits in
|
|
<BR> a group; elements with higher indices
|
|
<BR> are further left. An element with value
|
|
<BR> CHAR_MAX means that no further grouping
|
|
<BR> is done. An element with value 0 means
|
|
<BR> that the previous element is used for
|
|
<BR> all groups further left. */
|
|
<P>
|
|
<BR> /* Remaining fields are for monetary information */
|
|
<P>
|
|
<BR> char *int_curr_symbol; /* First three chars are a currency
|
|
<BR> symbol from ISO 4217. Fourth char
|
|
<BR> is the separator. Fifth char
|
|
<BR> is '\0'. */
|
|
<BR> char *currency_symbol; /* Local currency symbol */
|
|
<BR> char *mon_decimal_point; /* Radix character */
|
|
<BR> char *mon_thousands_sep; /* Like <I>thousands_sep</I> above */
|
|
<BR> char *mon_grouping; /* Like <I>grouping</I> above */
|
|
<BR> char *positive_sign; /* Sign for positive values */
|
|
<BR> char *negative_sign; /* Sign for negative values */
|
|
<BR> char int_frac_digits; /* International fractional digits */
|
|
<BR> char frac_digits; /* Local fractional digits */
|
|
<BR> char p_cs_precedes; /* 1 if currency_symbol precedes a
|
|
<BR> positive value, 0 if succeeds */
|
|
<BR> char p_sep_by_space; /* 1 if a space separates
|
|
<BR> currency_symbol from a positive
|
|
<BR> value */
|
|
<BR> char n_cs_precedes; /* 1 if currency_symbol precedes a
|
|
<BR> negative value, 0 if succeeds */
|
|
<BR> char n_sep_by_space; /* 1 if a space separates
|
|
<BR> currency_symbol from a negative
|
|
<BR> value */
|
|
<BR> /* Positive and negative sign positions:
|
|
<BR> 0 Parentheses surround the quantity and currency_symbol.
|
|
<BR> 1 The sign string precedes the quantity and currency_symbol.
|
|
<BR> 2 The sign string succeeds the quantity and currency_symbol.
|
|
<BR> 3 The sign string immediately precedes the currency_symbol.
|
|
<BR> 4 The sign string immediately succeeds the currency_symbol. */
|
|
<BR> char p_sign_posn;
|
|
<BR> char n_sign_posn;
|
|
};
|
|
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H3>POSIX.1-2008 extensions to the locale API</H3>
|
|
|
|
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 applications
|
|
and with applications that must deal with multiple locales.
|
|
<P>
|
|
|
|
The extensions take the form of new functions for creating and
|
|
manipulating locale objects
|
|
(<B><A HREF="/cgi-bin/man/man2html?3+newlocale">newlocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+freelocale">freelocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+duplocale">duplocale</A></B>(3),
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+uselocale">uselocale</A></B>(3))
|
|
|
|
and various new library functions with the suffix "_l" (e.g.,
|
|
<B><A HREF="/cgi-bin/man/man2html?3+toupper_l">toupper_l</A></B>(3))
|
|
|
|
that extend the traditional locale-dependent APIs (e.g.,
|
|
<B><A HREF="/cgi-bin/man/man2html?3+toupper">toupper</A></B>(3))
|
|
|
|
to allow the specification of a locale object that should apply when
|
|
executing the function.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>ENVIRONMENT</H2>
|
|
|
|
The following environment variable is used by
|
|
<B><A HREF="/cgi-bin/man/man2html?3+newlocale">newlocale</A></B>(3)
|
|
|
|
and
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3),
|
|
|
|
and thus affects all unprivileged localized programs:
|
|
<DL COMPACT>
|
|
<DT id="17"><B>LOCPATH</B>
|
|
|
|
<DD>
|
|
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
|
|
<I>LOCPATH</I>
|
|
|
|
and the system default locale data path are used;
|
|
any available locale archives are not used (see
|
|
<B><A HREF="/cgi-bin/man/man2html?1+localedef">localedef</A></B>(1)).
|
|
|
|
The individual compiled locale data files are searched for under
|
|
subdirectories which depend on the currently used locale.
|
|
For example, when
|
|
<I>en_GB.UTF-8</I>
|
|
|
|
is used for a category, the following subdirectories are searched for,
|
|
in this order:
|
|
<I>en_GB.UTF-8</I>,
|
|
|
|
<I>en_GB.utf8</I>,
|
|
|
|
<I>en_GB</I>,
|
|
|
|
<I>en.UTF-8</I>,
|
|
|
|
<I>en.utf8</I>,
|
|
|
|
and
|
|
<I>en</I>.
|
|
|
|
</DL>
|
|
<A NAME="lbAG"> </A>
|
|
<H2>FILES</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="18"><I>/usr/lib/locale/locale-archive</I>
|
|
|
|
<DD>
|
|
Usual default locale archive location.
|
|
<DT id="19"><I>/usr/lib/locale</I>
|
|
|
|
<DD>
|
|
Usual default path for compiled individual locale files.
|
|
</DL>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
POSIX.1-2001.
|
|
|
|
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+iconv">iconv</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+locale">locale</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+localedef">localedef</A></B>(1),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+catopen">catopen</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+gettext">gettext</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+iconv">iconv</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+localeconv">localeconv</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mbstowcs">mbstowcs</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+newlocale">newlocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+ngettext">ngettext</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+nl_langinfo">nl_langinfo</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+rpmatch">rpmatch</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strcoll">strcoll</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strfmon">strfmon</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strftime">strftime</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+strxfrm">strxfrm</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+uselocale">uselocale</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+wcstombs">wcstombs</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?5+locale">locale</A></B>(5),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+charsets">charsets</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+unicode">unicode</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+utf-8">utf-8</A></B>(7)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="20"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="21"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="22"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DL>
|
|
<DT id="23"><A HREF="#lbAE">POSIX.1-2008 extensions to the locale API</A><DD>
|
|
</DL>
|
|
<DT id="24"><A HREF="#lbAF">ENVIRONMENT</A><DD>
|
|
<DT id="25"><A HREF="#lbAG">FILES</A><DD>
|
|
<DT id="26"><A HREF="#lbAH">CONFORMING TO</A><DD>
|
|
<DT id="27"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="28"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:06:09 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|