Lowercase to Uppercase
#1

Okay, Most of users look for "Uppercase to Lowercase"
Now i'm doing opposite, I'm looking for "Lowercase to Uppercase"

I cannot find one i search everywhere, All i can find is Uppercase to Lowercase.

So how can i do this?
Reply
#2

Toupper
Reply
#3

pawn Код:
stock strToUpper(string[]) {
    new
        i = 0;
    while(EOS != string[i]) {
        if('a' <= string[i] <= 'z') string[i] -= 32;
        ++i;
    }
}
Reply
#4

You can either just minus 32 of the ASCII value per character or use https://sampwiki.blast.hk/wiki/Toupper

pawn Код:
new string[10] = "potato", id;
while(string[id] != EOS)
{
    string[id] = toupper(string[id]);
    id++;
}
Reply
#5

Misiur that didn't work, It returns my name instead of the parameter.

pawn Код:
format(string, sizeof(string), "[POLICE MEGAPHONE] %s(%d): %s", GetName(playerid), playerid, UpperWord(params));
Returns:

Код:
[POLICE MEGAPHONE]: Jake_Hero(0): Jake_Hero

instead of

[POLICE MEGAPHONE]: Jake_Hero(0): HEY STOP NOW
Reply
#6

The function shouldn't return anything. Try

pawn Код:
format(string, sizeof(string), "[POLICE MEGAPHONE] %s(%d): %s", GetName(playerid), playerid, (UpperWord(params), params));
Reply
#7

Misiur works now thanks, anyway [HiC]TheKiller i try your code and compile it in a blank script it gives error but nvm then.
Reply
#8

I don't remember if there's any performance diffrence, but if you don't want to use this comma thingy, you should be able to just add return to the stock

pawn Код:
stock UpperWord(string[]) {
    new
        i = 0;
    while(EOS != string[i]) {
        if('a' <= string[i] <= 'z') string[i] -= 32;
        ++i;
    }
    return string;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)