Blame man3/uselocale.3

Packit 7cfc04
'\" t
Packit 7cfc04
.\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
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
.TH USELOCALE 3 2017-09-15 "Linux" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
uselocale \- set/get the locale for the calling thread
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <locale.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "locale_t uselocale(locale_t " newloc );
Packit 7cfc04
.fi
Packit 7cfc04
.PP
Packit 7cfc04
.in -4n
Packit 7cfc04
Feature Test Macro Requirements for glibc (see
Packit 7cfc04
.BR feature_test_macros (7)):
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
.BR uselocale ():
Packit 7cfc04
.PD 0
Packit 7cfc04
.RS 4
Packit 7cfc04
.TP
Packit 7cfc04
Since glibc 2.10:
Packit 7cfc04
_XOPEN_SOURCE\ >=\ 700
Packit 7cfc04
.TP
Packit 7cfc04
Before glibc 2.10:
Packit 7cfc04
_GNU_SOURCE
Packit 7cfc04
.RE
Packit 7cfc04
.PD
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The
Packit 7cfc04
.BR uselocale ()
Packit 7cfc04
function sets the current locale for the calling thread,
Packit 7cfc04
and returns the thread's previously current locale.
Packit 7cfc04
After a successful call to
Packit 7cfc04
.BR uselocale (),
Packit 7cfc04
any calls by this thread to functions that depend on the locale
Packit 7cfc04
will operate as though the locale has been set to
Packit 7cfc04
.IR newloc .
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.I newloc
Packit 7cfc04
argument can have one of the following values:
Packit 7cfc04
.TP
Packit 7cfc04
A handle returned by a call to \fBnewlocale\fP(3) or \fBduplocale\fP(3)
Packit 7cfc04
The calling thread's current locale is set to the specified locale.
Packit 7cfc04
.TP
Packit 7cfc04
The special locale object handle \fBLC_GLOBAL_LOCALE\fP
Packit 7cfc04
The calling thread's current locale is set to the global locale determined by
Packit 7cfc04
.BR setlocale (3).
Packit 7cfc04
.TP
Packit 7cfc04
.I "(locale_t) 0"
Packit 7cfc04
The calling thread's current locale is left unchanged
Packit 7cfc04
(and the current locale is returned as the function result).
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR uselocale ()
Packit 7cfc04
returns the locale handle that was set by the previous call to
Packit 7cfc04
.BR uselocale ()
Packit 7cfc04
in this thread, or
Packit 7cfc04
.BR LC_GLOBAL_HANDLE
Packit 7cfc04
if there was no such previous call.
Packit 7cfc04
On error, it returns
Packit 7cfc04
.IR "(locale_t)\ 0",
Packit 7cfc04
and sets
Packit 7cfc04
.I errno
Packit 7cfc04
to indicate the cause of the error.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.I newloc
Packit 7cfc04
does not refer to a valid locale object.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
The
Packit 7cfc04
.BR uselocale ()
Packit 7cfc04
function first appeared in version 2.3 of the GNU C library.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2008.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
Unlike
Packit 7cfc04
.BR setlocale (3),
Packit 7cfc04
.BR uselocale ()
Packit 7cfc04
does not allow selective replacement of individual locale categories.
Packit 7cfc04
To employ a locale that differs in only a few categories from the current
Packit 7cfc04
locale, use calls to
Packit 7cfc04
.BR duplocale (3)
Packit 7cfc04
and
Packit 7cfc04
.BR newlocale (3)
Packit 7cfc04
to obtain a locale object equivalent to the current locale and
Packit 7cfc04
modify the desired categories in that object.
Packit 7cfc04
.SH EXAMPLE
Packit 7cfc04
See
Packit 7cfc04
.BR newlocale (3)
Packit 7cfc04
and
Packit 7cfc04
.BR duplocale (3).
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR locale (1),
Packit 7cfc04
.BR duplocale (3),
Packit 7cfc04
.BR freelocale (3),
Packit 7cfc04
.BR newlocale (3),
Packit 7cfc04
.BR setlocale (3),
Packit 7cfc04
.BR locale (5),
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/.