]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man3/toupper.3
ioctl_console.2, ctime.3: tfix
[thirdparty/man-pages.git] / man3 / toupper.3
1 .\" Copyright (c) 1993 by Thomas Koenig (ig25@rz.uni-karlsruhe.de)
2 .\" and Copyright 2014 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\"
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.
8 .\"
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.
13 .\"
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
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .\" Modified Sat Jul 24 17:45:39 1993 by Rik Faith (faith@cs.unc.edu)
27 .\" Modified 2000-02-13 by Nicolás Lichtmaier <nick@debian.org>
28 .TH TOUPPER 3 2017-09-15 "GNU" "Linux Programmer's Manual"
29 .SH NAME
30 toupper, tolower, toupper_l, tolower_l \- convert uppercase or lowercase
31 .SH SYNOPSIS
32 .nf
33 .B #include <ctype.h>
34 .PP
35 .BI "int toupper(int " "c" );
36 .BI "int tolower(int " "c" );
37 .PP
38 .BI "int toupper_l(int " c ", locale_t " locale );
39 .BI "int tolower_l(int " c ", locale_t " locale );
40 .fi
41 .PP
42 .in -4n
43 Feature Test Macro Requirements for glibc (see
44 .BR feature_test_macros (7)):
45 .in
46 .PP
47 .BR toupper_l (),
48 .BR tolower_l ():
49 .PD 0
50 .RS 4
51 .TP
52 Since glibc 2.10:
53 _XOPEN_SOURCE\ >=\ 700
54 .TP
55 Before glibc 2.10:
56 _GNU_SOURCE
57 .RE
58 .PD
59 .SH DESCRIPTION
60 These functions convert lowercase letters to uppercase, and vice versa.
61 .PP
62 If
63 .I c
64 is a lowercase letter,
65 .BR toupper ()
66 returns its uppercase equivalent,
67 if an uppercase representation exists in the current locale.
68 Otherwise, it returns
69 .IR c .
70 The
71 .BR toupper_l ()
72 function performs the same task,
73 but uses the locale referred to by the locale handle
74 .IR locale .
75 .PP
76 If
77 .I c
78 is an uppercase letter,
79 .BR tolower ()
80 returns its lowercase equivalent,
81 if a lowercase representation exists in the current locale.
82 Otherwise, it returns
83 .IR c .
84 The
85 .BR tolower_l ()
86 function performs the same task,
87 but uses the locale referred to by the locale handle
88 .IR locale .
89 .PP
90 If
91 .I c
92 is neither an
93 .I "unsigned char"
94 value nor
95 .BR EOF ,
96 the behavior of these functions
97 is undefined.
98 .PP
99 The behavior of
100 .BR toupper_l ()
101 and
102 .BR tolower_l ()
103 is undefined if
104 .I locale
105 is the special locale object
106 .BR LC_GLOBAL_LOCALE
107 (see
108 .BR duplocale (3))
109 or is not a valid locale object handle.
110 .SH RETURN VALUE
111 The value returned is that of the converted letter, or
112 .I c
113 if the conversion was not possible.
114 .SH ATTRIBUTES
115 For an explanation of the terms used in this section, see
116 .BR attributes (7).
117 .TS
118 allbox;
119 lbw24 lb lb
120 l l l.
121 Interface Attribute Value
122 T{
123 .BR toupper (),
124 .BR tolower (),
125 .br
126 .BR toupper_l (),
127 .BR tolower_l ()
128 T} Thread safety MT-Safe
129 .TE
130 .SH CONFORMING TO
131 .BR toupper (),
132 .BR tolower ():
133 C89, C99, 4.3BSD, POSIX.1-2001, POSIX.1-2008.
134 .PP
135 .BR toupper_l (),
136 .BR tolower_l ():
137 POSIX.1-2008.
138 .SH NOTES
139 The standards require that the argument
140 .I c
141 for these functions is either
142 .B EOF
143 or a value that is representable in the type
144 .IR "unsigned char" .
145 If the argument
146 .I c
147 is of type
148 .IR char ,
149 it must be cast to
150 .IR "unsigned char" ,
151 as in the following example:
152 .PP
153 .in +4n
154 .EX
155 char c;
156 \&...
157 res = toupper((unsigned char) c);
158 .EE
159 .in
160 .PP
161 This is necessary because
162 .I char
163 may be the equivalent
164 .IR "signed char" ,
165 in which case a byte where the top bit is set would be sign extended when
166 converting to
167 .IR int ,
168 yielding a value that is outside the range of
169 .IR "unsigned char" .
170 .PP
171 The details of what constitutes an uppercase or lowercase letter depend
172 on the locale.
173 For example, the default
174 .B """C"""
175 locale does not know about umlauts, so no conversion is done for them.
176 .PP
177 In some non-English locales, there are lowercase letters with no
178 corresponding uppercase equivalent;
179 .\" FIXME One day the statement about "sharp s" needs to be reworked,
180 .\" since there is nowadays a capital "sharp s" that has a codepoint
181 .\" in Unicode 5.0; see https://en.wikipedia.org/wiki/Capital_%E1%BA%9E
182 the German sharp s is one example.
183 .SH SEE ALSO
184 .BR isalpha (3),
185 .BR newlocale (3),
186 .BR setlocale (3),
187 .BR towlower (3),
188 .BR towupper (3),
189 .BR uselocale (3),
190 .BR locale (7)