Core Function Escape
From Sputnik Wiki
(Difference between revisions)
UberFoX (Talk | contribs)
(Created page with "<pre> Escape( <expression>, <custom> ) </pre> === Description === Add escapes to a string. === Parameters === ==== expression ==== The string to use. ==== custom ==== Opti...")
Newer edit →
(Created page with "<pre> Escape( <expression>, <custom> ) </pre> === Description === Add escapes to a string. === Parameters === ==== expression ==== The string to use. ==== custom ==== Opti...")
Newer edit →
Revision as of 16:18, 13 September 2013
Escape( <expression>, <custom> )
Contents |
Description
Add escapes to a string.
Parameters
expression
The string to use.
custom
Optional; A string containing characters to be escaped instead of escaping everything.
Return Value
Success: Returns a string with backslashes added. (' becomes \' and so on.).
Failure: Returns empty string.
Remarks
This adds escapes toa string regardless if the escape is valid or not so even # will be replaced with \#.
If you require more specific escape/unescape functions see the ones that deal with C/Sputnik specific escapes.
To properly escape and resolve Sputnik strings see ResolveStr( <expression> ).
Example
Escape everything
say Escape(@"Hello World!"); // Prints: \H\e\l\l\o\ \W\o\r\l\d\!
Escape only 'l' and 'o' characters
say Escape(@"Hello World!", 'lo'); // Prints: He\l\l\o W\or\ld!