Detect capital letters - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Detect capital letters (
/showthread.php?tid=77412)
Detect capital letters -
Danny_Costelo - 10.05.2009
Does anyone know, how i can detect capital letters?
Re: Detect capital letters -
Weirdosport - 10.05.2009
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.
Re: Detect capital letters -
Danny_Costelo - 10.05.2009
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?
Re: Detect capital letters -
Weirdosport - 10.05.2009
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
Re: Detect capital letters -
yom - 10.05.2009
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.
Re: Detect capital letters -
Weirdosport - 11.05.2009
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!
Re: Detect capital letters -
Donny_k - 11.05.2009
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