]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/uselocale.3
man3/t-v.3: srcfix: Use a single-font-style macro for a single argument
[thirdparty/man-pages.git] / man3 / uselocale.3
CommitLineData
aa14d1cd
MK
1'\" t
2.\" Copyright (C) 2014 Michael Kerrisk <mtk.manpages@gmail.com>
3.\"
4.\" %%%LICENSE_START(VERBATIM)
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
24.\" %%%LICENSE_END
25.\"
4b8c67d9 26.TH USELOCALE 3 2017-09-15 "Linux" "Linux Programmer's Manual"
aa14d1cd
MK
27.SH NAME
28uselocale \- set/get the locale for the calling thread
29.SH SYNOPSIS
30.nf
31.B #include <locale.h>
dbfe9c70 32.PP
aa14d1cd
MK
33.BI "locale_t uselocale(locale_t " newloc );
34.fi
68e4db0a 35.PP
aa14d1cd
MK
36.in -4n
37Feature Test Macro Requirements for glibc (see
38.BR feature_test_macros (7)):
39.in
68e4db0a 40.PP
aa14d1cd
MK
41.BR uselocale ():
42.PD 0
43.RS 4
44.TP
45Since glibc 2.10:
46_XOPEN_SOURCE\ >=\ 700
47.TP
48Before glibc 2.10:
49_GNU_SOURCE
50.RE
51.PD
52.SH DESCRIPTION
53The
54.BR uselocale ()
55function sets the current locale for the calling thread,
56and returns the thread's previously current locale.
57After a successful call to
58.BR uselocale (),
59any calls by this thread to functions that depend on the locale
60will operate as though the locale has been set to
61.IR newloc .
847e0d88 62.PP
aa14d1cd
MK
63The
64.I newloc
65argument can have one of the following values:
66.TP
67A handle returned by a call to \fBnewlocale\fP(3) or \fBduplocale\fP(3)
68The calling thread's current locale is set to the specified locale.
69.TP
70The special locale object handle \fBLC_GLOBAL_LOCALE\fP
71The calling thread's current locale is set to the global locale determined by
72.BR setlocale (3).
73.TP
74.I "(locale_t) 0"
75The calling thread's current locale is left unchanged
76(and the current locale is returned as the function result).
77.SH RETURN VALUE
78On success,
79.BR uselocale ()
80returns the locale handle that was set by the previous call to
81.BR uselocale ()
82in this thread, or
d8a86e74 83.B LC_GLOBAL_LOCALE
aa14d1cd
MK
84if there was no such previous call.
85On error, it returns
d8a86e74 86.IR "(locale_t)\ 0" ,
aa14d1cd
MK
87and sets
88.I errno
89to indicate the cause of the error.
90.SH ERRORS
91.TP
92.B EINVAL
93.I newloc
94does not refer to a valid locale object.
95.SH VERSIONS
96The
97.BR uselocale ()
98function first appeared in version 2.3 of the GNU C library.
99.SH CONFORMING TO
100POSIX.1-2008.
101.SH NOTES
102Unlike
103.BR setlocale (3),
104.BR uselocale ()
105does not allow selective replacement of individual locale categories.
106To employ a locale that differs in only a few categories from the current
107locale, use calls to
108.BR duplocale (3)
109and
110.BR newlocale (3)
111to obtain a locale object equivalent to the current locale and
112modify the desired categories in that object.
113.SH EXAMPLE
114See
115.BR newlocale (3)
116and
117.BR duplocale (3).
118.SH SEE ALSO
119.BR locale (1),
120.BR duplocale (3),
121.BR freelocale (3),
122.BR newlocale (3),
123.BR setlocale (3),
124.BR locale (5),
125.BR locale (7)