1 .\" (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and 1999 by Bruno Haible (haible@clisp.cons.org)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" Modified Sat Jul 24 18:20:12 1993 by Rik Faith (faith@cs.unc.edu)
25 .\" Modified Tue Jul 15 16:49:10 1997 by Andries Brouwer (aeb@cwi.nl)
26 .\" Modified Sun Jul 4 14:52:16 1999 by Bruno Haible (haible@clisp.cons.org)
27 .\" Modified Tue Aug 24 17:11:01 1999 by Andries Brouwer (aeb@cwi.nl)
28 .\" Modified Tue Feb 6 03:31:55 2001 by Andries Brouwer (aeb@cwi.nl)
30 .TH SETLOCALE 3 1999-07-04 "GNU" "Linux Programmer's Manual"
32 setlocale \- set the current locale
35 .B #include <locale.h>
37 .BI "char *setlocale(int " category ", const char *" locale );
42 function is used to set or query the program's current locale.
47 the program's current locale is modified according to the arguments.
50 determines which parts of the program's current locale should be modified.
53 for all of the locale.
56 for regular expression matching (it determines the meaning
57 of range expressions and equivalence classes) and string collation.
60 for regular expression matching, character classification, conversion,
61 case-sensitive comparison, and wide character functions.
64 for localizable natural-language messages.
67 for monetary formatting.
70 for number formatting (such as the decimal point and the thousands separator).
73 for time and date formatting.
77 is a pointer to a character string containing the
80 Such a string is either a well-known constant like "C" or "da_DK"
81 (see below), or an opaque string that was returned by another call of
88 each part of the locale that should be modified is set according to the
89 environment variables.
90 The details are implementation dependent.
92 .\" [This is false on my system - must check which library versions do this]
95 .\" is LC_MESSAGES, the environment variable LANGUAGE is inspected,
99 the environment variable
102 next the environment variable with the same name as the category
109 and finally the environment variable
111 The first existing environment variable is used.
112 If its value is not a valid locale specification, the locale
116 .\" The environment variable LANGUAGE may contain several, colon-separated,
123 is a portable locale; its
125 part corresponds to the 7-bit ASCII
128 A locale name is typically of the form
129 .IR language "[_" territory "][." codeset "][@" modifier "],"
132 is an ISO 639 language code,
134 is an ISO 3166 country code, and
136 is a character set or encoding identifier like
140 For a list of all supported locales, try "locale \-a", cf.\&
145 is NULL, the current locale is only queried, not modified.
147 On startup of the main program, the portable
149 locale is selected as default.
150 A program may be made portable to all locales by calling
151 .B setlocale(LC_ALL, """""")
152 after program initialization, by using the values returned
156 for locale-dependent information, by using the multi-byte and wide
157 character functions for text processing if
158 .BR "MB_CUR_MAX > 1" ,
169 returns an opaque string that corresponds to the locale set.
170 This string may be allocated in static storage.
171 The string returned is such that a subsequent call with that string
172 and its associated category will restore that part of the process's
174 The return value is NULL if the request cannot be honored.
176 C89, C99, POSIX.1-2001.
178 Linux (that is, GNU libc) supports the portable locales
179 .BR """C""" " and " """POSIX""" .
180 In the good old days there used to be support for
183 locale (e.g., in libc-4.5.21 and libc-4.6.27), and the Russian
185 (more precisely, "koi-8r") locale (e.g., in libc-4.6.27),
186 so that having an environment variable \fILC_CTYPE=ISO-8859-1\fP
189 return the right answer.
190 These days non-English speaking Europeans have to work a bit harder,
191 and must install actual locale files.