1TOUPPER(3) Linux Programmer's Manual TOUPPER(3)
2
3
4
6 toupper, tolower, toupper_l, tolower_l - convert uppercase or lowercase
7
9 #include <ctype.h>
10
11 int toupper(int c);
12 int tolower(int c);
13
14 int toupper_l(int c, locale_t locale);
15 int tolower_l(int c, locale_t locale);
16
17 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19 toupper_l(), tolower_l():
20 Since glibc 2.10:
21 _XOPEN_SOURCE >= 700
22 Before glibc 2.10:
23 _GNU_SOURCE
24
26 These functions convert lowercase letters to uppercase, and vice versa.
27
28 If c is a lowercase letter, toupper() returns its uppercase equivalent,
29 if an uppercase representation exists in the current locale. Other‐
30 wise, it returns c. The toupper_l() function performs the same task,
31 but uses the locale referred to by the locale handle locale.
32
33 If c is an uppercase letter, tolower() returns its lowercase equiva‐
34 lent, if a lowercase representation exists in the current locale. Oth‐
35 erwise, it returns c. The tolower_l() function performs the same task,
36 but uses the locale referred to by the locale handle locale.
37
38 If c is neither an unsigned char value nor EOF, the behavior of these
39 functions is undefined.
40
41 The behavior of toupper_l() and tolower_l() is undefined if locale is
42 the special locale object LC_GLOBAL_LOCALE (see duplocale(3)) or is not
43 a valid locale object handle.
44
46 The value returned is that of the converted letter, or c if the conver‐
47 sion was not possible.
48
50 For an explanation of the terms used in this section, see
51 attributes(7).
52
53 ┌─────────────────────────┬───────────────┬─────────┐
54 │Interface │ Attribute │ Value │
55 ├─────────────────────────┼───────────────┼─────────┤
56 │toupper(), tolower(), │ Thread safety │ MT-Safe │
57 │toupper_l(), tolower_l() │ │ │
58 └─────────────────────────┴───────────────┴─────────┘
60 toupper(), tolower(): C89, C99, 4.3BSD, POSIX.1-2001, POSIX.1-2008.
61
62 toupper_l(), tolower_l(): POSIX.1-2008.
63
65 The standards require that the argument c for these functions is either
66 EOF or a value that is representable in the type unsigned char. If the
67 argument c is of type char, it must be cast to unsigned char, as in the
68 following example:
69
70 char c;
71 ...
72 res = toupper((unsigned char) c);
73
74 This is necessary because char may be the equivalent signed char, in
75 which case a byte where the top bit is set would be sign extended when
76 converting to int, yielding a value that is outside the range of
77 unsigned char.
78
79 The details of what constitutes an uppercase or lowercase letter depend
80 on the locale. For example, the default "C" locale does not know about
81 umlauts, so no conversion is done for them.
82
83 In some non-English locales, there are lowercase letters with no corre‐
84 sponding uppercase equivalent; the German sharp s is one example.
85
87 isalpha(3), newlocale(3), setlocale(3), towlower(3), towupper(3), use‐
88 locale(3), locale(7)
89
91 This page is part of release 5.02 of the Linux man-pages project. A
92 description of the project, information about reporting bugs, and the
93 latest version of this page, can be found at
94 https://www.kernel.org/doc/man-pages/.
95
96
97
98GNU 2017-09-15 TOUPPER(3)