Why do some versions of toupper act strangely if given an upper-case letter? Why
does some code call islower before toupper?
In earlier times, toupper was a function-like preprocessor macro and was defined
to work only on lower-case letters; it misbehaved if applied to digits, punctuation,
or letters which were already upper-case. Similarly, tolower worked only on upper-case
letters. Therefore, old code (or code written for wide portability) tends to call
islower before toupper, and isupper before tolower.
The C Standard, however, says that toupper and tolower must work correctly on all
characters, i.e. characters which don't need changing are left alone.