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 2008-12-05 "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.
55 for all of the locale.
58 for regular expression matching (it determines the meaning
59 of range expressions and equivalence classes) and string collation.
62 for regular expression matching, character classification, conversion,
63 case-sensitive comparison, and wide character functions.
66 for localizable natural-language messages.
69 for monetary formatting.
72 for number formatting (such as the decimal point and the thousands separator).
75 for time and date formatting.
79 is a pointer to a character string containing the
82 Such a string is either a well-known constant like "C" or "da_DK"
83 (see below), or an opaque string that was returned by another call of
90 each part of the locale that should be modified is set according to the
91 environment variables.
92 The details are implementation-dependent.
93 For glibc, first (regardless of
95 the environment variable
98 next the environment variable with the same name as the category
105 and finally the environment variable
107 The first existing environment variable is used.
108 If its value is not a valid locale specification, the locale
117 is a portable locale; its
119 part corresponds to the 7-bit ASCII
122 A locale name is typically of the form
123 .IR language "[_" territory "][." codeset "][@" modifier "],"
126 is an ISO 639 language code,
128 is an ISO 3166 country code, and
130 is a character set or encoding identifier like
134 For a list of all supported locales, try "locale \-a", cf.\&
139 is NULL, the current locale is only queried, not modified.
141 On startup of the main program, the portable
143 locale is selected as default.
144 A program may be made portable to all locales by calling:
147 setlocale(LC_ALL, "");
150 after program initialization, by using the values returned
154 for locale-dependent information, by using the multibyte and wide
155 character functions for text processing if
156 .BR "MB_CUR_MAX > 1" ,
167 returns an opaque string that corresponds to the locale set.
168 This string may be allocated in static storage.
169 The string returned is such that a subsequent call with that string
170 and its associated category will restore that part of the process's
172 The return value is NULL if the request cannot be honored.
174 C89, C99, POSIX.1-2001.
176 Linux (that is, glibc) supports the portable locales
177 .BR """C""" " and " """POSIX""" .
178 In the good old days there used to be support for
181 locale (e.g., in libc-4.5.21 and libc-4.6.27), and the Russian
183 (more precisely, "koi-8r") locale (e.g., in libc-4.6.27),
184 so that having an environment variable \fILC_CTYPE=ISO-8859-1\fP
187 return the right answer.
188 These days non-English speaking Europeans have to work a bit harder,
189 and must install actual locale files.
202 This page is part of release 3.67 of the Linux
205 A description of the project,
206 information about reporting bugs,
207 and the latest version of this page,
209 \%http://www.kernel.org/doc/man\-pages/.