[DGD] case conversion
Par Winzell
zell at skotos.net
Tue Jan 6 23:15:28 CET 2004
DGD strings are copy-on-write...
string lower_case(string str) {
int i;
for (i = 0; i < strlen(str); i ++) {
if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] = (str[i] - 'A' + 'a');
}
}
return str;
}
On Tue, 2004-01-06 at 15:39, Robert Forshaw 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
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list