1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and Copyright 1999 by Bruno Haible (haible@clisp.cons.org)
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .\" Modified Sat Jul 24 18:20:12 1993 by Rik Faith (faith@cs.unc.edu)
27 .\" Modified Tue Jul 15 16:49:10 1997 by Andries Brouwer (aeb@cwi.nl)
28 .\" Modified Sun Jul 4 14:52:16 1999 by Bruno Haible (haible@clisp.cons.org)
29 .\" Modified Tue Aug 24 17:11:01 1999 by Andries Brouwer (aeb@cwi.nl)
30 .\" Modified Tue Feb 6 03:31:55 2001 by Andries Brouwer (aeb@cwi.nl)
32 .TH SETLOCALE 3 2021-03-22 "GNU" "Linux Programmer's Manual"
34 setlocale \- set the current locale
37 .B #include <locale.h>
39 .BI "char *setlocale(int " category ", const char *" locale );
44 function is used to set or query the program's current locale.
49 the program's current locale is modified according to the arguments.
52 determines which parts of the program's current locale should be modified.
59 LC_ALL All of the locale
61 Formatting of addresses and
62 geography-related items (*)
64 LC_COLLATE String collation
65 LC_CTYPE Character classification
67 Metadata describing the locale (*)
70 Settings related to measurements
71 (metric versus US customary) (*)
74 Localizable natural-language messages
77 Formatting of monetary values
80 Formatting of salutations for persons (*)
83 Formatting of nonmonetary numeric values
86 Settings related to the standard paper size (*)
89 Formats to be used with telephone services (*)
92 Formatting of date and time values
98 The categories marked with an asterisk in the above table
100 For further information on these locale categories, see
105 is a pointer to a character string containing the
108 Such a string is either a well-known constant like "C" or "da_DK"
109 (see below), or an opaque string that was returned by another call of
116 each part of the locale that should be modified is set according to the
117 environment variables.
118 The details are implementation-dependent.
119 For glibc, first (regardless of
121 the environment variable
124 next the environment variable with the same name as the category
125 (see the table above),
126 and finally the environment variable
128 The first existing environment variable is used.
129 If its value is not a valid locale specification, the locale
138 is a portable locale;
139 it exists on all conforming systems.
141 A locale name is typically of the form
142 .IR language "[_" territory "][." codeset "][@" modifier "],"
145 is an ISO 639 language code,
147 is an ISO 3166 country code, and
149 is a character set or encoding identifier like
153 For a list of all supported locales, try "locale \-a" (see
158 is NULL, the current locale is only queried, not modified.
160 On startup of the main program, the portable
162 locale is selected as default.
163 A program may be made portable to all locales by calling:
167 setlocale(LC_ALL, "");
171 after program initialization, and then:
173 using the values returned from a
175 call for locale-dependent information;
177 using the multibyte and wide character functions for text processing if
178 .BR "MB_CUR_MAX > 1" ;
184 to compare strings; and
190 to compare wide-character strings.
194 returns an opaque string that corresponds to the locale set.
195 This string may be allocated in static storage.
196 The string returned is such that a subsequent call with that string
197 and its associated category will restore that part of the process's
199 The return value is NULL if the request cannot be honored.
201 For an explanation of the terms used in this section, see
209 Interface Attribute Value
212 T} Thread safety MT-Unsafe const:locale env
218 POSIX.1-2001, POSIX.1-2008, C89, C99.
220 The C standards specify only the categories
230 The remaining categories are GNU extensions.