Assuming that A..Z and a..z are contiguous in the character set (not guaranteed, but for our purposes we can consider it to be so for all practical platforms), 'a' - 'A' will give you a transformation necessary to convert to lower case.
For example, if 'a' is 98, and 'A' is 65, then adding (98-65 = 33) to a character will make it lower case.
Test case: 'B' is 66, 'b' is 99. 'B' + 33 == 'b'.
05 Aug, 2010, David Haley wrote in the 3rd comment:
Votes: 0
You're better off using the standard function tolower; it will get the nasty details right in case the characters aren't contiguous etc. as Kaz pointed out, although as he said for all practical intents and purposes they will be.
Apparently it's standard ROM. I'm moving it to std::string and came across this in the one_argument function, I wanted to be certain to convert things properly. :)
Thanks guys.
EDIT: Wouldn't this be less overhead than calling another function tolower() ? All this talk of ROM cutting corners…
You're talking about a trivial amount of overhead.
By this rationale replacing any given function with macro expansion would be desirable. Macros have increasingly been frowned upon for the last 20 or so years now.
05 Aug, 2010, David Haley wrote in the 7th comment:
Votes: 0
The compiler will sometimes online tiny functions anyhow, especially if they're stdlib. Regardless as Runter said the overhead is tiny.
06 Aug, 2010, JohnnyStarr wrote in the 8th comment:
Which muds did you play in the 90s, kaz? There was a kaz that fits your personality on a small one I frequented.
Probably not me. I played with my full nick back then, Kastagaar. I was mainly on Land of Legends (not the one whose implementor is on these forums, the old one that closed), and occasionally A Moment in Tyme. I also implemented for Continents Mud (which, I'm happy to say, is still around. If anyone plays it, say hello to the crew from me!)
This just checks whether c is a letter of the alphabet and if so, it does © + 'a' - 'A' … Since the name is lower I assume it converts to lowercase, but how?