Debian Codegraph @

upstream/debian-unstable/man3/uselocale.3

raw
1 .\" Copyright 2014, Michael Kerrisk <[email protected]>
2 .\" Copyright, the authors of the Linux man-pages project
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH uselocale 3 2026-02-08 "Linux man-pages 6.18"
7 .SH NAME
8 uselocale \- set/get the locale for the calling thread
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ,\~ \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <locale.h>
15 .P
16 .BI "locale_t uselocale(locale_t " newloc );
17 .fi
18 .P
19 .RS -4
20 Feature Test Macro Requirements for glibc (see
21 .BR feature_test_macros (7)):
22 .RE
23 .P
24 .BR uselocale ():
25 .nf
26 Since glibc 2.10:
27 _XOPEN_SOURCE >= 700
28 Before glibc 2.10:
29 _GNU_SOURCE
30 .fi
31 .SH DESCRIPTION
32 The
33 .BR uselocale ()
34 function sets the current locale for the calling thread,
35 and returns the thread's previously current locale.
36 After a successful call to
37 .BR uselocale (),
38 any calls by this thread to functions that depend on the locale
39 will operate as though the locale has been set to
40 .IR newloc .
41 .P
42 The
43 .I newloc
44 argument can have one of the following values:
45 .TP
46 A handle returned by a call to
47 .BR newlocale (3)
48 or
49 .BR duplocale (3)
50 The calling thread's current locale is set to the specified locale.
51 .TP
52 The special locale object handle
53 .B LC_GLOBAL_LOCALE
54 The calling thread's current locale is set to the global locale determined by
55 .BR setlocale (3).
56 .TP
57 .I "(locale_t) 0"
58 The calling thread's current locale is left unchanged
59 (and the current locale is returned as the function result).
60 .SH RETURN VALUE
61 On success,
62 .BR uselocale ()
63 returns the locale handle that was set by the previous call to
64 .BR uselocale ()
65 in this thread, or
66 .B LC_GLOBAL_LOCALE
67 if there was no such previous call.
68 On error, it returns
69 .IR "(locale_t)\ 0" ,
70 and sets
71 .I errno
72 to indicate the error.
73 .SH ERRORS
74 .TP
75 .B EINVAL
76 .I newloc
77 does not refer to a valid locale object.
78 .SH STANDARDS
79 POSIX.1-2008.
80 .SH HISTORY
81 glibc 2.3.
82 POSIX.1-2008.
83 .SH NOTES
84 Unlike
85 .BR setlocale (3),
86 .BR uselocale ()
87 does not allow selective replacement of individual locale categories.
88 To employ a locale that differs in only a few categories from the current
89 locale, use calls to
90 .BR duplocale (3)
91 and
92 .BR newlocale (3)
93 to obtain a locale object equivalent to the current locale and
94 modify the desired categories in that object.
95 .SH EXAMPLES
96 See
97 .BR newlocale (3)
98 and
99 .BR duplocale (3).
100 .SH SEE ALSO
101 .BR locale (1),
102 .BR duplocale (3),
103 .BR freelocale (3),
104 .BR newlocale (3),
105 .BR setlocale (3),
106 .BR locale (5),
107 .BR locale (7)