[DGD] case conversion

Noah Gibbs noah_gibbs at yahoo.com
Tue Jan 6 23:07:11 CET 2004


  Rather than "ch[0] = str[count++]", you probably
want something like "count++, ch = str[count..count]",
which will set ch to be a one-character string
containing str[count] as its only character.

  Alternately, you could extract the character as an
int to alter it, or alter it directly as str[count].

--- Robert Forshaw <iouswuoibev at hotmail.com> wrote:
> My case conversion function doesn't work.
> 
> string lower_case(string str)
> {
> 	string ch;
> 	int count, len;
> 
> 	if(str == nil || str == "") return "";
> 
> 	len = strlen(str);
> 
> 	for(count = 0; count < len; ch[0] = str[count++])
> 	{
> 		if(ch[0] > 64 && ch[0] < 97) str[count] = ch[0] +
> 32;
> 	}
> 
> 	return str;
> }
> 
> I've observed (incorrectly?) that the only way to
> refer to a char rather 
> than a string is to refer to an element of a string
> (all other drivers I've 
> seen return a string with a single char). I'm
> assuming that you can also 
> manipulate and compare a char as if it were an 8 bit
> integer, in order to 
> modify its case. Are these assumptions correct?
> Incidently, the lower_case() 
> function gets the following error:
> "Index on bad type".
> 
> Any help would be appreciated.
> 
>
_________________________________________________________________
> It's fast, it's easy and it's free. Get MSN
> Messenger today! 
> http://www.msn.co.uk/messenger
> 
>
_________________________________________________________________
> List config page: 
http://list.imaginary.com/mailman/listinfo/dgd


=====
------
noah_gibbs at yahoo.com

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list