Detect capital letters
#1

Does anyone know, how i can detect capital letters?
Reply
#2

As far as strings are concerned, A and a are different ascii characters, so if you were to use Switch:

pawn Код:
switch(letter){
case a: //blah
case A: //blah
}
They are 2 different entities.
Reply
#3

Quote:
Originally Posted by Weirdosport
As far as strings are concerned, A and a are different ascii characters, so if you were to use Switch:

pawn Код:
switch(letter){
case a: //blah
case A: //blah
}
They are 2 different entities.
Uh what? So i would have to do that for every letter?
Reply
#4

Well I'm no expert in the field, but I'd guess you'd have to use a for/while loop to "scroll" through all of the characters in the string, then use a big switch thing to detect and eradicate capitals..

for(new a=0; a<strlen(string); a++)
{
switch(string[a])
{
case A: string[a] = a;
case B: string[a] = b;
}
}

NOTE: Except I'd expect you to use indentation :P
Reply
#5

Lower case characters is range 0x61 - 0x7A, and upper case characters is range 0x41 - 0x5A. This is only for characters a-z and A-Z, not а or А or whatever. To convert a upper character to a lower character, add 0x20, and, as you already guessed i think, for lower to upper, substract 0x20.
Reply
#6

Quote:
Originally Posted by 0rb
Lower case characters is range 0x61 - 0x7A, and upper case characters is range 0x41 - 0x5A. This is only for characters a-z and A-Z, not а or А or whatever. To convert a upper character to a lower character, add 0x20, and, as you already guessed i think, for lower to upper, substract 0x20.
I feel enlightened as always!
Reply
#7

From my anti script, learn from it etc:

pawn Код:
#if !defined NO_CAPS_PROTECTION
        #define UpperToLower(%1) for ( new ToLowerChar; ToLowerChar < strlen( %1 ); ToLowerChar ++ ) if ( %1[ ToLowerChar ] > 64 && %1[ ToLowerChar ] < 91 ) %1[ ToLowerChar ] += 32
    #endif
It's in decimal, 0x20 is 32, it's two full hex bits as they are limited to 16 so like I dunno say 74 is 0x4A as it's 4 * 16 + 10 (A is the 10). Hehehe a little hex lesson
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)