Raised This Month: $ Target: $400
 0% 

%x


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 05-08-2007 , 09:54   %x
Reply With Quote #1

Does format( ) support %x, %X specifiers?

According to this, it does.
According to my output and funcwiki, it does not.
alien is offline
Send a message via ICQ to alien
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 05-08-2007 , 10:04   Re: %x
Reply With Quote #2

And according to this, it should. Am I just running and old Amxmodx? Well ... thanks anyway.
alien is offline
Send a message via ICQ to alien
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-08-2007 , 10:17   Re: %x
Reply With Quote #3

Quote:
Originally Posted by alien View Post
And according to this, it should. Am I just running and old Amxmodx? Well ... thanks anyway.

Quote:
Reported Version 1.76d
Due in Version 1.8
You will have to wait a little bit till version 1.8 is out ;)

btw.: your first link is a sourcemod link ;)
(http://wiki.amxmodx.org/Format_Class...d_Scripting%29)
__________________
regalis is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 05-08-2007 , 10:48   Re: %x
Reply With Quote #4

Yes, I've noticed it's from SourceMod Couldn't wait ... had to code it :/ Thnx.
alien is offline
Send a message via ICQ to alien
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-08-2007 , 10:53   Re: %x
Reply With Quote #5

May i ask you for what reason you need to print a number in hexadecimal radix?
Just wonder in what case this will be used.

greetz regalis
__________________
regalis is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 05-08-2007 , 11:08   Re: %x
Reply With Quote #6

Sure! ... I'm sending HTTP GET / POST requests to web servers ... in case, I'm sending something like player names, these have to be URL-safe-encoded. And to do that, I need hex.

Well, this is what I have so far - I've got a bug inside, don't know where:

PHP Code:
url_safe(unsafe_string[], safe_string[])
    {
        new 
unsafe[] =
            {
                
0x240x260x2b0x2c0x2f0x3a0x3b0x3d0x3f0x40,
                
0x200x220x3c0x230x250x7b0x7c0x7d0x5c0x5e0x7e0x5b0x5d0x60
            
}

        new 
safe[][4] =
            {
                
"%24""%26""%2b""%2c""%2f""%3a""%3b""%3d""%3f""%40",
                
"%20""%22""%3c""%23""%25""%7b""%7c""%7d""%5c""%5e""%7e""%5b""%5d""%60"
            
}

        new
            
length strlen(unsafe_string),
            
max_length length 3

        
for (new 0lengthi++)
            {
                for (new 
024j++)
                    {
                        
server_print("%d = %d"unsafe_string[i], unsafe[j])

                        if (
unsafe_string[i] == unsafe[j])
                            {
                                
format(safe_stringmax_length"%s%s"safe_stringsafe[j])

                                break;
                            }
                        else 
format(safe_stringmax_length"%s%c"safe_stringunsafe_string[i])
                    }

                
server_print(safe_string)
            }
    } 
alien is offline
Send a message via ICQ to alien
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 05-08-2007 , 11:37   Re: %x
Reply With Quote #7

Seems to work fine ... but there could be bugs inside.
Just in the case someone would need it:

PHP Code:
url_safe(unsafe_string[], safe_string[])
    {
        new 
unsafe[] =
            {
                
0x240x260x2b0x2c0x2f0x3a0x3b0x3d0x3f0x40,
                
0x200x220x3c0x230x250x7b0x7c0x7d0x5c0x5e0x7e0x5b0x5d0x60
            
}

        new 
safe[][4] =
            {
                
"%24""%26""%2b""%2c""%2f""%3a""%3b""%3d""%3f""%40",
                
"%20""%22""%3c""%23""%25""%7b""%7c""%7d""%5c""%5e""%7e""%5b""%5d""%60"
            
}

        new
            
length strlen(unsafe_string),
            
max_length length 3

        
for (new 0lengthi++)
            {
                new 
bool:safe_char true

                
for (new 024j++)
                    {
                        if (
unsafe_string[i] == unsafe[j])
                            {
                                
format(safe_stringmax_length"%s%s"safe_stringsafe[j])
                                
safe_char false

                                
break;
                            }
                    }

                if (
safe_charformat(safe_stringmax_length"%s%c"safe_stringunsafe_string[i])
            }
    } 
alien is offline
Send a message via ICQ to alien
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 05-08-2007 , 11:48   Re: %x
Reply With Quote #8

hmm, i think i have to get more into hex ;)
don't realy understand that, luckily i don't need it *puhh*

thanks for sharing this
greetz regalis
__________________
regalis is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-08-2007 , 11:49   Re: %x
Reply With Quote #9

This has already been done I believe:
http://forums.alliedmods.net/showthr...highlight=HTTP
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 05-08-2007 , 11:52   Re: %x
Reply With Quote #10

Woa, thanks Zenith77 ... but that's decode, function above is encoder. But I was in need of this as well. Cheers.
alien is offline
Send a message via ICQ to alien
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode