prev up next   top/contents search

comp.lang.c FAQ list · Question 13.5

Q: Why do some versions of toupper act strangely if given an upper-case letter?
Why does some code call islower before toupper?


A: 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.

References: ISO Sec. 7.3.2
H&S Sec. 12.9 pp. 320-1
PCS p. 182


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North