C tolower() function

Programming, for all ages and all languages.
Post Reply
Guest

C tolower() function

Post by Guest »

Hi,

Is it part of the c standard for the tolower() and toupper() functions to first check for an alpha char before performing the conversion?

thanks.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:C tolower() function

Post by df »

non alpha dont have upper/lower case. and afaik, is not defined to work on non-english languages.?

so only A-Za-z work for ansi toupper/tolower
-- Stu --
Guest

Re:C tolower() function

Post by Guest »

Thanks, I understand that, but what I mean is if a semi-colon (0x3b) is passed to the tolower() function, it will attempt to clear bit 5, which of course should not be done, so does it check for an alpha character before perofming the operation or does it just blindly clear bit 5?

thanks again.
Tim

Re:C tolower() function

Post by Tim »

tolower and toupper will handle non-alphabetic characters correctly.

From http://www.dinkumware.com/manuals/reader.aspx?b=p/&h=ctype.html#tolower:

tolower
[tt]int tolower(int c);[/tt]
The function returns the corresponding lowercase letter if one exists and if [tt]isupper(c)[/tt]; otherwise, it returns [tt]c[/tt].

toupper
[tt]int toupper(int c);[/tt]
The function returns the corresponding uppercase letter if one exists and if [tt]islower(c)[/tt]; otherwise, it returns [tt]c[/tt].
Post Reply