S&box Wiki

Sandbox.StringX

Sandbox.StringX

A class to add functionality to the string library. A lot of these methods are also extensions, so you can use for example str safe = badstring.QuoteSafe()

Methods

static string Base64Decode( string base64EncodedData )
Convert from a base64 encoded string
static string Base64Encode( string plainText )
Convert to a base64 encoded string
static string Columnize( string str, int maxLength, bool right = False )
convert "string" into "string " or " string"
static bool Contains( string source, string toCheck, System.StringComparison comp )
An extended Contains which takes a StringComparison
static int FastHash( string str )
static int GetSha256( string self )
Returns the SHA256 of this string.
static string NormalizeFilename( string str )
Puts a filename into the format /path/filename. ext (from path\FileName. EXT)
static string QuoteSafe( string str )
Puts quote marks around a string. Internal quotes are backslashed.
static string RemoveBadCharacters( string str )
Removes bad, invisible characters that are commonly used to exploit. https://en.wikipedia.org/wiki/Zero-width_non-joiner
static string Snippet( string source, string find, int padding )
Given a large string, find all occurrances of a substring and return them with padding. This is useful in situations where you're searching for a word in a hug body of text, and want to show how it's used without displaying the whole text.
static System.String[] SplitQuotesStrings( string input )
in : I am "splitting a" string "because it's fun " out : ["I", "am", "splitting a", "string", "because it's fun"]
static bool ToBool( string str )
Try to convert to bool. Inputs can be true, false, yes, no, 0, 1, null (caps insensitive)
static System.Decimal ToDecimal( string str, System.Decimal Default = 0 )
128-bit data type that returns sane results for almost any input. All other numeric types can cast from this.
static float ToFloat( string str, float Default = 0 )
Convert to float, if not then return Default
static int ToInt( string str, int Default = 0 )
Convert to int, if not then return Default
static string ToTitleCase( string source )
Convert a variable name to something more user friendly
static object ToType( string str, System.Type t )
Try to politely convert from a string to another type
static uint ToUInt( string str, int Default = 0 )
Convert to uint, if not then return Default
static ulong ToULong( string str, ulong Default = 0 )
Convert to int, if not then return Default
static string Truncate( string str, int maxLength, string appendage )
If the string is longer than this amount of characters then truncate it If appendage is defined, it will be appended to the end of truncated strings (ie, "..")
static string TruncateFilename( string str, int maxLength, string appendage )
If the string is longer than this amount of characters then truncate it If appendage is defined, it will be appended to the end of truncated strings (ie, "..")
static bool TryToType( string str, System.Type t, object Value )
Try to politely convert from a string to another type
static bool WildcardMatch( string str, string wildcard )
Returns true if tjhis string matches a wildcard match

Special Pages


Wikis

?

Render Time: 49ms

DB GetPage 37
Generate Html 1
SaveChanges (1) 6
Render Body 0
Render Sidebar 1