Algorithm only of numbers
#1

I need the algorithm which converting string (any letters, symbols, numbers) to numbers (can be ASCII). On php I've seen that there are this functions, but on pawn - not.

Hm, what could explain how to write this functions, or explain how to write.
On pawn I'm not novice.
Thanks.
Reply
#2

Nobody can help?
Reply
#3

You can use this table to see the values of each character and then make a custom function: http://www.asciitable.com/

Here is the format of the function (I cannot be bothered to do the whole thing):
pawn Код:
SymbolToASCII(char)
{
    switch(char)
    {
        case ' ': return 32;
        case '!': return 33;
        // etc....
    }
    return -1;
}
Reply
#4

@Bakr, I wanna encoding not one symbol, I wanna encoding long text, with different symbols, numbers.

Example:
Код:
new Text[126] = "Hello all. 123. @$@%@. {FF0000}Red.";
encodeToASCII(Text); // Print, ex: 46498489498
decodeFromASCII(Text); // Print: Hello all. 123. @$@%@. {FF0000}Red.
Reply
#5

Only way I can honestly think of doing this would be to loop through each character in the string then get its corresponding ASCII decimal value, storing that into another string (strcat).

As for the decoding, that is another problem as each character can have different numbers that take more characters to display (i.e. ' ' = 32, 'i' = 105). You would need some sort of delimiter inserted between characters.
Reply
#6

I have one mind.

I call with HTTP() function .php file from my hosting and on here call php decode/uncode functions.
Reply
#7

Yeah, that would work. I've never personally used the HTTP function so cannot say how efficient that would be, but definitely worth trying.
Reply
#8

Thank you, ******.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)