Raised This Month: $51 Target: $400
 12% 

% in string text


Post New Thread Reply   
 
Thread Tools Display Modes
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-21-2015 , 19:07   Re: % in string text
Reply With Quote #11

Quote:
Originally Posted by KissLick View Post
This was mentioned here many times. The right answer is %%.

Always when the string is formated (Format, FormatEx, PrintTo* functions etc.) it converts %% to %.
So, if you format your string twice, you need to use %%%% - first format output is %% and second format output is %.
No, the answer is to not double-format, as it generally implies massive security bugs.
__________________
asherkin is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 07-22-2015 , 00:46   Re: % in string text
Reply With Quote #12

Quote:
Originally Posted by asherkin View Post
No, the answer is to not double-format, as it generally implies massive security bugs.
Example? (For my own educational benefit.)
Potato Uno is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 07-22-2015 , 09:35   Re: % in string text
Reply With Quote #13

%s in some user input would crash it
Miu is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 07-23-2015 , 06:14   Re: % in string text
Reply With Quote #14

Don't want great new post so type my question here..
Code:
Format(sText, sizeof(sText), "%c%c%c%s", 1, 11, 1, sText);
What means %c format prm 1 and 11?

Tnx
ZASTRELIS is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 07-23-2015 , 06:23   Re: % in string text
Reply With Quote #15

Quote:
Originally Posted by ZASTRELIS View Post
Don't want great new post so type my question here..
Code:
Format(sText, sizeof(sText), "%c%c%c%s", 1, 11, 1, sText);

What means %c format prm 1 and 11?

Tnx
1 and 11 are just numbers, or in this case, numbers that represent ASCII characters. %c is a character format specifier, which means that it prints just a single character.
Here's a little reference/guide to format specifiers: http://www.cplusplus.com/reference/cstdio/printf/
klippy is offline
ZASTRELIS
Veteran Member
Join Date: Nov 2010
Location: Siberia, Irkutsk
Old 07-23-2015 , 08:04   Re: % in string text
Reply With Quote #16

Quote:
Originally Posted by KliPPy View Post
1 and 11 are just numbers, or in this case, numbers that represent ASCII characters. %c is a character format specifier, which means that it prints just a single character.
Here's a little reference/guide to format specifiers: http://www.cplusplus.com/reference/cstdio/printf/
hmm.. wt's this (1) start of heading?
ZASTRELIS is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 07-23-2015 , 08:05   Re: % in string text
Reply With Quote #17

The low ASCII codes are used for colouring chat text.
__________________
asherkin is offline
Reply



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 12:09.


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