Is there a good example of how toupper() works?

Zev Sero zvs at bby.oz.au
Mon Nov 12 11:52:45 AEST 1990


>>>>> On 7 Nov 90 04:37:05 GMT, karl at robot.in-berlin.de (Karl-P. Huestegge) said:
Karl> One additional advice: Please don't use isascii() in text-functions,
Karl> because this forbits all international chars > 127. Use isprint()
Karl> instead (or whatever is appropriate).

Unfortunately, in many implementations, including SunOS, the only
ctype.h functions/macros that are guaranteed to work on chars >127 are
isascii and toascii.  If you want your code to work on such systems,
i.e. you are doing things like 
  c = isupper (c) ? tolower (c) : c;
which is unnecessary in standard C, then you must also use isascii.
  c = isascii (c) && isupper (c) ? tolower (c) : c;

To find out whether a character can safely be sent to a printer, in
such an implementation, you must use 
  if (isascii (c) && isprint (c))
otherwise, as I learned the hard way, your program will dump core.
---
                                Zev Sero  -  zvs at bby.oz.au
As I recall, zero was invented by Arabic mathematicians
thousands of years ago.  It's a pity it still frightens
or confuses people.           - Doug Gwyn



More information about the Comp.lang.c mailing list