View Full Version : Escaping Format Specifiers
Is there a method to escape format specifiers such as %i, %s, %f, etc?
I could iterate through the string and remove format specifiers from the user input but I'd prefer a method that allowed the input, but treated it as a regular string rather than a placeholder.
Powerlord
10-25-2014, 22:22
Any particular reason you need to do this?
If you pass a string to format for a %s modifier, it won't process any modifiers in it.
i.e.
Format(myString, sizeof(myString), "%s", userInput);
Any particular reason you need to do this?
If you pass a string to format for a %s modifier, it won't process any modifiers in it.
i.e.
Format(myString, sizeof(myString), "%s", userInput);
I'll try that out, PrintToChat definitely doesn't honor this system. Doing this:
PrintToChat(client, "%s", message); while message contains a %s causes the message to be cut off with an error hitting the client console:
Bad format string in CLocalizeStringTable::ConstructString
Edit: Format is not doing it, I think it has to do with PrintToChat.
Edit 2: I can see two % signs can be used to escape a single % sign, too bad the solution isn't as simple as using %%s to escape %s.
Leonardo
10-26-2014, 05:13
%%
%%
That does not work for escaping %s. That only works for escaping a single % see the posting I made some time ago.
Leonardo
10-26-2014, 07:17
That does not work for escaping %s. That only works for escaping a single % see the posting I made some time ago.
so %%s wont work?
EDIT:
also, built-in chat processor would replace a single % (0x25) with space (0x20).
KissLick
10-26-2014, 07:56
Not tested, but what about?\%s
vBulletin® v3.8.7, Copyright ©2000-2024, vBulletin Solutions, Inc.