1SETLOCALE(3)               Linux Programmer's Manual              SETLOCALE(3)
2
3
4

NAME

6       setlocale - set the current locale
7

SYNOPSIS

9       #include <locale.h>
10
11       char *setlocale(int category, const char *locale);
12

DESCRIPTION

14       The  setlocale() function is used to set or query the program's current
15       locale.
16
17       If locale is not NULL, the program's current locale is modified accord‐
18       ing  to the arguments.  The argument category determines which parts of
19       the program's current locale should be modified.
20
21       LC_ALL for all of the locale.
22
23       LC_COLLATE
24              for regular expression matching (it determines  the  meaning  of
25              range expressions and equivalence classes) and string collation.
26
27       LC_CTYPE
28              for  regular expression matching, character classification, con‐
29              version, case-sensitive comparison,  and  wide  character  func‐
30              tions.
31
32       LC_MESSAGES
33              for localizable natural-language messages.
34
35       LC_MONETARY
36              for monetary formatting.
37
38       LC_NUMERIC
39              for  number  formatting (such as the decimal point and the thou‐
40              sands separator).
41
42       LC_TIME
43              for time and date formatting.
44
45       The argument locale is a pointer to a character string  containing  the
46       required  setting  of  category.   Such a string is either a well-known
47       constant like "C" or "da_DK" (see below), or an opaque string that  was
48       returned by another call of setlocale().
49
50       If locale is "", each part of the locale that should be modified is set
51       according to the environment variables.  The  details  are  implementa‐
52       tion-dependent.   For  glibc, first (regardless of category), the envi‐
53       ronment variable LC_ALL is inspected,  next  the  environment  variable
54       with  the same name as the category (LC_COLLATE, LC_CTYPE, LC_MESSAGES,
55       LC_MONETARY, LC_NUMERIC, LC_TIME) and finally the environment  variable
56       LANG.   The  first existing environment variable is used.  If its value
57       is not a valid locale specification, the locale is unchanged, and  set‐
58       locale() returns NULL.
59
60       The  locale "C" or "POSIX" is a portable locale; its LC_CTYPE part cor‐
61       responds to the 7-bit ASCII character set.
62
63       A locale name is  typically  of  the  form  language[_territory][.code‐
64       set][@modifier],  where language is an ISO 639 language code, territory
65       is an ISO 3166 country code, and codeset is a character set or encoding
66       identifier  like  ISO-8859-1  or  UTF-8.   For  a list of all supported
67       locales, try "locale -a", cf. locale(1).
68
69       If locale is NULL, the current locale is only queried, not modified.
70
71       On startup of the main program, the portable "C" locale is selected  as
72       default.  A program may be made portable to all locales by calling:
73
74           setlocale(LC_ALL, "");
75
76       after  program  initialization,  by  using  the  values returned from a
77       localeconv(3) call  for  locale-dependent  information,  by  using  the
78       multi-byte   and  wide  character  functions  for  text  processing  if
79       MB_CUR_MAX > 1, and by  using  strcoll(3),  wcscoll(3)  or  strxfrm(3),
80       wcsxfrm(3) to compare strings.
81

RETURN VALUE

83       A  successful  call to setlocale() returns an opaque string that corre‐
84       sponds to the locale set.  This string may be allocated in static stor‐
85       age.   The  string  returned  is  such that a subsequent call with that
86       string and its associated  category  will  restore  that  part  of  the
87       process's  locale.   The  return value is NULL if the request cannot be
88       honored.
89

CONFORMING TO

91       C89, C99, POSIX.1-2001.
92

NOTES

94       Linux (that is, glibc) supports the portable locales "C"  and  "POSIX".
95       In  the good old days there used to be support for the European Latin-1
96       "ISO-8859-1" locale (e.g., in libc-4.5.21  and  libc-4.6.27),  and  the
97       Russian   "KOI-8"   (more   precisely,   "koi-8r")   locale  (e.g.,  in
98       libc-4.6.27),    so    that    having    an    environment     variable
99       LC_CTYPE=ISO-8859-1  sufficed  to  make  isprint(3)  return  the  right
100       answer.  These days non-English speaking Europeans have to work  a  bit
101       harder, and must install actual locale files.
102

SEE ALSO

104       locale(1),  localedef(1),  isalpha(3),  localeconv(3),  nl_langinfo(3),
105       rpmatch(3), strcoll(3), strftime(3), charsets(7), locale(7)
106

COLOPHON

108       This page is part of release 3.22 of the Linux  man-pages  project.   A
109       description  of  the project, and information about reporting bugs, can
110       be found at http://www.kernel.org/doc/man-pages/.
111
112
113
114GNU                               2008-12-05                      SETLOCALE(3)
Impressum