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 2017-09-15 "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.
57 LC_ALL All of the locale
59 Formatting of addresses and
61 geography-related items (*)
63 LC_COLLATE String collation
64 LC_CTYPE Character classification
65 LC_IDENTIFICATION Metadata describing the locale (*)
67 Settings related to measurements
69 (metric versus US customary) (*)
71 LC_MESSAGES Localizable natural-language messages
72 LC_MONETARY Formatting of monetary values
73 LC_NAME Formatting of salutations for persons (*)
74 LC_NUMERIC Formatting of nonmonetary numeric values
75 LC_PAPER Settings related to the standard paper size (*)
76 LC_TELEPHONE Formats to be used with telephone services (*)
77 LC_TIME Formatting of date and time values
80 The categories marked with an asterisk in the above table
82 For further information on these locale categories, see
87 is a pointer to a character string containing the
90 Such a string is either a well-known constant like "C" or "da_DK"
91 (see below), or an opaque string that was returned by another call of
98 each part of the locale that should be modified is set according to the
99 environment variables.
100 The details are implementation-dependent.
101 For glibc, first (regardless of
103 the environment variable
106 next the environment variable with the same name as the category
107 (see the table above),
108 and finally the environment variable
110 The first existing environment variable is used.
111 If its value is not a valid locale specification, the locale
120 is a portable locale;
121 it exists on all conforming systems.
123 A locale name is typically of the form
124 .IR language "[_" territory "][." codeset "][@" modifier "],"
127 is an ISO 639 language code,
129 is an ISO 3166 country code, and
131 is a character set or encoding identifier like
135 For a list of all supported locales, try "locale \-a" (see
140 is NULL, the current locale is only queried, not modified.
142 On startup of the main program, the portable
144 locale is selected as default.
145 A program may be made portable to all locales by calling:
149 setlocale(LC_ALL, "");
153 after program initialization, by using the values returned
157 for locale-dependent information, by using the multibyte and wide
158 character functions for text processing if
159 .BR "MB_CUR_MAX > 1" ,
170 returns an opaque string that corresponds to the locale set.
171 This string may be allocated in static storage.
172 The string returned is such that a subsequent call with that string
173 and its associated category will restore that part of the process's
175 The return value is NULL if the request cannot be honored.
177 For an explanation of the terms used in this section, see
183 Interface Attribute Value
186 T} Thread safety MT-Unsafe const:locale env
190 POSIX.1-2001, POSIX.1-2008, C89, C99.
192 The C standards specify only the categories
202 The remaining categories are GNU extensions.