Page 1 of 1
C tolower() function
Posted: Fri Jan 17, 2003 7:57 am
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.
Re:C tolower() function
Posted: Fri Jan 17, 2003 11:40 am
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
Re:C tolower() function
Posted: Sat Jan 18, 2003 3:16 am
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.
Re:C tolower() function
Posted: Sat Jan 18, 2003 7:33 am
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].