Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!unido!opal!tmpmbx!utopia!robot!karl From: karl@robot.in-berlin.de (Karl-P. Huestegge) Newsgroups: comp.lang.c Subject: Re: Is there a good example of how toupper() works? Keywords: converting upper/lower case macros Message-ID: <1990Nov7.043705.15051@robot.in-berlin.de> Date: 7 Nov 90 04:37:05 GMT References: <1990Oct17.170914.683@wpi.WPI.EDU> <11021@hubcap.clemson.edu> <152580@felix.UUCP> Organization: K.-P. Huestegge, Sytemanalyse und Beratung, Berlin Lines: 34 asylvain@felix.UUCP (Alvin "the Chipmunk" Sylvain) writes: >In fact, defining this macro is *dangerous*. Using a locally defined >"toupper" routine from the standard *guarantees* that the local >hardware has been taken into account. Furthermore, this is one more thing >you don't have to debug. Have you tested that macro over the entire ASCII >character set? Checked 'a', '`', '@', 'A', 'Z', '[', 'z', '{', etc.? >(boundary checks) >Conclusion: If there is a standard routine that does what you want, *use it*. >This increases reliability and portability and reduces debug time. If you're >not sure what the routine does, RTFM and/or get help. If you not sure that >something you want to do has already been done, ask someone. Good chance >it's already been done. Sorry, I missed the starting point of the discussion. There is another reason to use the standard library functions: The international Charactersets (8bit, ISO-8859-1 for example). On my international development system toupper('a-umlaut') is ('A-umlaut'), which is of course *not* 'a-umlaut'-32 or ('a-umlaut' - 'a'-'A'). The functions accesses a library of the local language-set (depending on the environment-var LC_CTYPE) One additional advice: Please don't use isascii() in text-functions, because this forbits all international chars > 127. Use isprint() instead (or whatever is appropriate). Please keep your code 8-bit clean. Thousands of Users thank you. (all the Renes, Angeliques, Mullers and Angstroms would be happy ;-). -- Karl-Peter Huestegge karl@robot.in-berlin.de Berlin Friedenau ..unido!fub!geminix!robot!karl