|
Packit |
7cfc04 |
.\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
|
|
Packit |
7cfc04 |
.\" and Copyright 1999 by Bruno Haible (haible@clisp.cons.org)
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_START(VERBATIM)
|
|
Packit |
7cfc04 |
.\" Permission is granted to make and distribute verbatim copies of this
|
|
Packit |
7cfc04 |
.\" manual provided the copyright notice and this permission notice are
|
|
Packit |
7cfc04 |
.\" preserved on all copies.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Permission is granted to copy and distribute modified versions of this
|
|
Packit |
7cfc04 |
.\" manual under the conditions for verbatim copying, provided that the
|
|
Packit |
7cfc04 |
.\" entire resulting derived work is distributed under the terms of a
|
|
Packit |
7cfc04 |
.\" permission notice identical to this one.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
Packit |
7cfc04 |
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
Packit |
7cfc04 |
.\" responsibility for errors or omissions, or for damages resulting from
|
|
Packit |
7cfc04 |
.\" the use of the information contained herein. The author(s) may not
|
|
Packit |
7cfc04 |
.\" have taken the same level of care in the production of this manual,
|
|
Packit |
7cfc04 |
.\" which is licensed free of charge, as they might when working
|
|
Packit |
7cfc04 |
.\" professionally.
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
Packit |
7cfc04 |
.\" the source, must acknowledge the copyright and authors of this work.
|
|
Packit |
7cfc04 |
.\" %%%LICENSE_END
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.\" Modified Sat Jul 24 18:20:12 1993 by Rik Faith (faith@cs.unc.edu)
|
|
Packit |
7cfc04 |
.\" Modified Tue Jul 15 16:49:10 1997 by Andries Brouwer (aeb@cwi.nl)
|
|
Packit |
7cfc04 |
.\" Modified Sun Jul 4 14:52:16 1999 by Bruno Haible (haible@clisp.cons.org)
|
|
Packit |
7cfc04 |
.\" Modified Tue Aug 24 17:11:01 1999 by Andries Brouwer (aeb@cwi.nl)
|
|
Packit |
7cfc04 |
.\" Modified Tue Feb 6 03:31:55 2001 by Andries Brouwer (aeb@cwi.nl)
|
|
Packit |
7cfc04 |
.\"
|
|
Packit |
7cfc04 |
.TH SETLOCALE 3 2017-09-15 "GNU" "Linux Programmer's Manual"
|
|
Packit |
7cfc04 |
.SH NAME
|
|
Packit |
7cfc04 |
setlocale \- set the current locale
|
|
Packit |
7cfc04 |
.SH SYNOPSIS
|
|
Packit |
7cfc04 |
.nf
|
|
Packit |
7cfc04 |
.B #include <locale.h>
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.BI "char *setlocale(int " category ", const char *" locale );
|
|
Packit |
7cfc04 |
.fi
|
|
Packit |
7cfc04 |
.SH DESCRIPTION
|
|
Packit |
7cfc04 |
The
|
|
Packit |
7cfc04 |
.BR setlocale ()
|
|
Packit |
7cfc04 |
function is used to set or query the program's current locale.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I locale
|
|
Packit |
7cfc04 |
is not NULL,
|
|
Packit |
7cfc04 |
the program's current locale is modified according to the arguments.
|
|
Packit |
7cfc04 |
The argument
|
|
Packit |
7cfc04 |
.I category
|
|
Packit |
7cfc04 |
determines which parts of the program's current locale should be modified.
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
lB lB
|
|
Packit |
7cfc04 |
lB l.
|
|
Packit |
7cfc04 |
Category Governs
|
|
Packit |
7cfc04 |
LC_ALL All of the locale
|
|
Packit |
7cfc04 |
LC_ADDRESS T{
|
|
Packit |
7cfc04 |
Formatting of addresses and
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
geography-related items (*)
|
|
Packit |
7cfc04 |
T}
|
|
Packit |
7cfc04 |
LC_COLLATE String collation
|
|
Packit |
7cfc04 |
LC_CTYPE Character classification
|
|
Packit |
7cfc04 |
LC_IDENTIFICATION Metadata describing the locale (*)
|
|
Packit |
7cfc04 |
LC_MEASUREMENT T{
|
|
Packit |
7cfc04 |
Settings related to measurements
|
|
Packit |
7cfc04 |
.br
|
|
Packit |
7cfc04 |
(metric versus US customary) (*)
|
|
Packit |
7cfc04 |
T}
|
|
Packit |
7cfc04 |
LC_MESSAGES Localizable natural-language messages
|
|
Packit |
7cfc04 |
LC_MONETARY Formatting of monetary values
|
|
Packit |
7cfc04 |
LC_NAME Formatting of salutations for persons (*)
|
|
Packit |
7cfc04 |
LC_NUMERIC Formatting of nonmonetary numeric values
|
|
Packit |
7cfc04 |
LC_PAPER Settings related to the standard paper size (*)
|
|
Packit |
7cfc04 |
LC_TELEPHONE Formats to be used with telephone services (*)
|
|
Packit |
7cfc04 |
LC_TIME Formatting of date and time values
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The categories marked with an asterisk in the above table
|
|
Packit |
7cfc04 |
are GNU extensions.
|
|
Packit |
7cfc04 |
For further information on these locale categories, see
|
|
Packit |
7cfc04 |
.BR locale (7).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The argument
|
|
Packit |
7cfc04 |
.I locale
|
|
Packit |
7cfc04 |
is a pointer to a character string containing the
|
|
Packit |
7cfc04 |
required setting of
|
|
Packit |
7cfc04 |
.IR category .
|
|
Packit |
7cfc04 |
Such a string is either a well-known constant like "C" or "da_DK"
|
|
Packit |
7cfc04 |
(see below), or an opaque string that was returned by another call of
|
|
Packit |
7cfc04 |
.BR setlocale ().
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I locale
|
|
Packit |
7cfc04 |
is an empty string,
|
|
Packit |
7cfc04 |
.BR """""" ,
|
|
Packit |
7cfc04 |
each part of the locale that should be modified is set according to the
|
|
Packit |
7cfc04 |
environment variables.
|
|
Packit |
7cfc04 |
The details are implementation-dependent.
|
|
Packit |
7cfc04 |
For glibc, first (regardless of
|
|
Packit |
7cfc04 |
.IR category ),
|
|
Packit |
7cfc04 |
the environment variable
|
|
Packit |
7cfc04 |
.B LC_ALL
|
|
Packit |
7cfc04 |
is inspected,
|
|
Packit |
7cfc04 |
next the environment variable with the same name as the category
|
|
Packit |
7cfc04 |
(see the table above),
|
|
Packit |
7cfc04 |
and finally the environment variable
|
|
Packit |
7cfc04 |
.BR LANG .
|
|
Packit |
7cfc04 |
The first existing environment variable is used.
|
|
Packit |
7cfc04 |
If its value is not a valid locale specification, the locale
|
|
Packit |
7cfc04 |
is unchanged, and
|
|
Packit |
7cfc04 |
.BR setlocale ()
|
|
Packit |
7cfc04 |
returns NULL.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The locale
|
|
Packit |
7cfc04 |
.B """C"""
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.B """POSIX"""
|
|
Packit |
7cfc04 |
is a portable locale;
|
|
Packit |
7cfc04 |
it exists on all conforming systems.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
A locale name is typically of the form
|
|
Packit |
7cfc04 |
.IR language "[_" territory "][." codeset "][@" modifier "],"
|
|
Packit |
7cfc04 |
where
|
|
Packit |
7cfc04 |
.I language
|
|
Packit |
7cfc04 |
is an ISO 639 language code,
|
|
Packit |
7cfc04 |
.I territory
|
|
Packit |
7cfc04 |
is an ISO 3166 country code, and
|
|
Packit |
7cfc04 |
.I codeset
|
|
Packit |
7cfc04 |
is a character set or encoding identifier like
|
|
Packit |
7cfc04 |
.B "ISO-8859-1"
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR "UTF-8" .
|
|
Packit |
7cfc04 |
For a list of all supported locales, try "locale \-a" (see
|
|
Packit |
7cfc04 |
.BR locale (1)).
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
If
|
|
Packit |
7cfc04 |
.I locale
|
|
Packit |
7cfc04 |
is NULL, the current locale is only queried, not modified.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
On startup of the main program, the portable
|
|
Packit |
7cfc04 |
.B """C"""
|
|
Packit |
7cfc04 |
locale is selected as default.
|
|
Packit |
7cfc04 |
A program may be made portable to all locales by calling:
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
.in +4n
|
|
Packit |
7cfc04 |
.EX
|
|
Packit |
7cfc04 |
setlocale(LC_ALL, "");
|
|
Packit |
7cfc04 |
.EE
|
|
Packit |
7cfc04 |
.in
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
after program initialization, by using the values returned
|
|
Packit |
7cfc04 |
from a
|
|
Packit |
7cfc04 |
.BR localeconv (3)
|
|
Packit |
7cfc04 |
call
|
|
Packit |
7cfc04 |
for locale-dependent information, by using the multibyte and wide
|
|
Packit |
7cfc04 |
character functions for text processing if
|
|
Packit |
7cfc04 |
.BR "MB_CUR_MAX > 1" ,
|
|
Packit |
7cfc04 |
and by using
|
|
Packit |
7cfc04 |
.BR strcoll (3),
|
|
Packit |
7cfc04 |
.BR wcscoll (3)
|
|
Packit |
7cfc04 |
or
|
|
Packit |
7cfc04 |
.BR strxfrm (3),
|
|
Packit |
7cfc04 |
.BR wcsxfrm (3)
|
|
Packit |
7cfc04 |
to compare strings.
|
|
Packit |
7cfc04 |
.SH RETURN VALUE
|
|
Packit |
7cfc04 |
A successful call to
|
|
Packit |
7cfc04 |
.BR setlocale ()
|
|
Packit |
7cfc04 |
returns an opaque string that corresponds to the locale set.
|
|
Packit |
7cfc04 |
This string may be allocated in static storage.
|
|
Packit |
7cfc04 |
The string returned is such that a subsequent call with that string
|
|
Packit |
7cfc04 |
and its associated category will restore that part of the process's
|
|
Packit |
7cfc04 |
locale.
|
|
Packit |
7cfc04 |
The return value is NULL if the request cannot be honored.
|
|
Packit |
7cfc04 |
.SH ATTRIBUTES
|
|
Packit |
7cfc04 |
For an explanation of the terms used in this section, see
|
|
Packit |
7cfc04 |
.BR attributes (7).
|
|
Packit |
7cfc04 |
.TS
|
|
Packit |
7cfc04 |
allbox;
|
|
Packit |
7cfc04 |
lb lb lbw26
|
|
Packit |
7cfc04 |
l l l.
|
|
Packit |
7cfc04 |
Interface Attribute Value
|
|
Packit |
7cfc04 |
T{
|
|
Packit |
7cfc04 |
.BR setlocale ()
|
|
Packit |
7cfc04 |
T} Thread safety MT-Unsafe const:locale env
|
|
Packit |
7cfc04 |
.TE
|
|
Packit |
7cfc04 |
.sp 1
|
|
Packit |
7cfc04 |
.SH CONFORMING TO
|
|
Packit |
7cfc04 |
POSIX.1-2001, POSIX.1-2008, C89, C99.
|
|
Packit |
7cfc04 |
.PP
|
|
Packit |
7cfc04 |
The C standards specify only the categories
|
|
Packit |
7cfc04 |
.BR LC_ALL ,
|
|
Packit |
7cfc04 |
.BR LC_COLLATE ,
|
|
Packit |
7cfc04 |
.BR LC_CTYPE ,
|
|
Packit |
7cfc04 |
.BR LC_MONETARY ,
|
|
Packit |
7cfc04 |
.BR LC_NUMERIC ,
|
|
Packit |
7cfc04 |
and
|
|
Packit |
7cfc04 |
.BR LC_TIME .
|
|
Packit |
7cfc04 |
POSIX.1 adds
|
|
Packit |
7cfc04 |
.BR LC_MESSAGES .
|
|
Packit |
7cfc04 |
The remaining categories are GNU extensions.
|
|
Packit |
7cfc04 |
.SH SEE ALSO
|
|
Packit |
7cfc04 |
.BR locale (1),
|
|
Packit |
7cfc04 |
.BR localedef (1),
|
|
Packit |
7cfc04 |
.BR isalpha (3),
|
|
Packit |
7cfc04 |
.BR localeconv (3),
|
|
Packit |
7cfc04 |
.BR nl_langinfo (3),
|
|
Packit |
7cfc04 |
.BR rpmatch (3),
|
|
Packit |
7cfc04 |
.BR strcoll (3),
|
|
Packit |
7cfc04 |
.BR strftime (3),
|
|
Packit |
7cfc04 |
.BR charsets (7),
|
|
Packit |
7cfc04 |
.BR locale (7)
|
|
Packit |
7cfc04 |
.SH COLOPHON
|
|
Packit |
7cfc04 |
This page is part of release 4.15 of the Linux
|
|
Packit |
7cfc04 |
.I man-pages
|
|
Packit |
7cfc04 |
project.
|
|
Packit |
7cfc04 |
A description of the project,
|
|
Packit |
7cfc04 |
information about reporting bugs,
|
|
Packit |
7cfc04 |
and the latest version of this page,
|
|
Packit |
7cfc04 |
can be found at
|
|
Packit |
7cfc04 |
\%https://www.kernel.org/doc/man\-pages/.
|