man-pages/man3/uselocale.3.html
2021-03-31 01:06:50 +01:00

200 lines
4.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of USELOCALE</TITLE>
</HEAD><BODY>
<H1>USELOCALE</H1>
Section: Linux Programmer's Manual (3)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
uselocale - set/get the locale for the calling thread
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/locale.h">locale.h</A>&gt;</B>
<B>locale_t uselocale(locale_t </B><I>newloc</I><B>);</B>
</PRE>
<P>
Feature Test Macro Requirements for glibc (see
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7)):
<P>
<B>uselocale</B>():
<DL COMPACT><DT id="1"><DD>
<DL COMPACT>
<DT id="2">Since glibc 2.10:<DD>
_XOPEN_SOURCE&nbsp;&gt;=&nbsp;700
<DT id="3">Before glibc 2.10:<DD>
_GNU_SOURCE
</DL>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
The
<B>uselocale</B>()
function sets the current locale for the calling thread,
and returns the thread's previously current locale.
After a successful call to
<B>uselocale</B>(),
any calls by this thread to functions that depend on the locale
will operate as though the locale has been set to
<I>newloc</I>.
<P>
The
<I>newloc</I>
argument can have one of the following values:
<DL COMPACT>
<DT id="4">A handle returned by a call to <B><A HREF="/cgi-bin/man/man2html?3+newlocale">newlocale</A></B>(3) or <B><A HREF="/cgi-bin/man/man2html?3+duplocale">duplocale</A></B>(3)<DD>
The calling thread's current locale is set to the specified locale.
<DT id="5">The special locale object handle <B>LC_GLOBAL_LOCALE</B><DD>
The calling thread's current locale is set to the global locale determined by
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3).
<DT id="6"><I>(locale_t) 0</I>
<DD>
The calling thread's current locale is left unchanged
(and the current locale is returned as the function result).
</DL>
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
On success,
<B>uselocale</B>()
returns the locale handle that was set by the previous call to
<B>uselocale</B>()
in this thread, or
<B>LC_GLOBAL_LOCALE</B>
if there was no such previous call.
On error, it returns
<I>(locale_t)&nbsp;0</I>,
and sets
<I>errno</I>
to indicate the cause of the error.
<A NAME="lbAF">&nbsp;</A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT id="7"><B>EINVAL</B>
<DD>
<I>newloc</I>
does not refer to a valid locale object.
</DL>
<A NAME="lbAG">&nbsp;</A>
<H2>VERSIONS</H2>
The
<B>uselocale</B>()
function first appeared in version 2.3 of the GNU C library.
<A NAME="lbAH">&nbsp;</A>
<H2>CONFORMING TO</H2>
POSIX.1-2008.
<A NAME="lbAI">&nbsp;</A>
<H2>NOTES</H2>
Unlike
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3),
<B>uselocale</B>()
does not allow selective replacement of individual locale categories.
To employ a locale that differs in only a few categories from the current
locale, use calls to
<B><A HREF="/cgi-bin/man/man2html?3+duplocale">duplocale</A></B>(3)
and
<B><A HREF="/cgi-bin/man/man2html?3+newlocale">newlocale</A></B>(3)
to obtain a locale object equivalent to the current locale and
modify the desired categories in that object.
<A NAME="lbAJ">&nbsp;</A>
<H2>EXAMPLE</H2>
See
<B><A HREF="/cgi-bin/man/man2html?3+newlocale">newlocale</A></B>(3)
and
<B><A HREF="/cgi-bin/man/man2html?3+duplocale">duplocale</A></B>(3).
<A NAME="lbAK">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?1+locale">locale</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?3+duplocale">duplocale</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+freelocale">freelocale</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+newlocale">newlocale</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+setlocale">setlocale</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?5+locale">locale</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?7+locale">locale</A></B>(7)
<A NAME="lbAL">&nbsp;</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">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="8"><A HREF="#lbAB">NAME</A><DD>
<DT id="9"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="10"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="11"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="12"><A HREF="#lbAF">ERRORS</A><DD>
<DT id="13"><A HREF="#lbAG">VERSIONS</A><DD>
<DT id="14"><A HREF="#lbAH">CONFORMING TO</A><DD>
<DT id="15"><A HREF="#lbAI">NOTES</A><DD>
<DT id="16"><A HREF="#lbAJ">EXAMPLE</A><DD>
<DT id="17"><A HREF="#lbAK">SEE ALSO</A><DD>
<DT id="18"><A HREF="#lbAL">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:05:59 GMT, March 31, 2021
</BODY>
</HTML>