Home

toupperunsigned

toupperunsigned is a non-standard function name used in some codebases to convert an unsigned character or code point to its uppercase form. It is not defined by the C or C++ standard, and its exact behavior depends on the library or project in which it appears. The name typically signals that the input should be treated as unsigned to ensure defined behavior for characters outside the ASCII range.

In its simplest form, a locale-agnostic variant maps ASCII lowercase letters to uppercase: if ch is in

Common prototypes include unsigned int toupperunsigned(unsigned int ch) and unsigned char toupperunsigned(unsigned char ch). Using an

In portable code, developers should document the expected input domain and consider using a Unicode-capable library

the
range
'a'
to
'z',
it
returns
ch
-
('a'-'A');
otherwise
it
returns
ch
unchanged.
A
Unicode-aware
variant
expands
this
to
map
a
much
larger
set
of
script-specific
lowercase
letters
to
their
uppercase
equivalents,
following
Unicode
case
mappings
and,
if
applicable,
locale
data.
Such
mappings
are
usually
provided
by
a
dedicated
library
(for
example
ICU)
or
by
platform
APIs.
unsigned
input
helps
avoid
undefined
behavior
when
feeding
values
outside
the
signed
char
range.
When
only
ASCII
is
required,
the
standard
toupper
from
<ctype.h>
suffices,
provided
the
input
is
cast
to
unsigned
char.
for
non-ASCII
text.
See
also
toupper,
towupper,
and
Unicode
case
mapping
resources.