While playing around with the Reflector today, I chanced about the StringUtil class inside the Kernel.
If you are working with a lot of links in Sitecore, you would have encountered the function EnsurePrefix, that takes in a char and a string as arguments; this is one of the members of this class. Aside from this uber useful utility here are a list of what you can also pick up and use inside this sealed class.
If you are working with a lot of links in Sitecore, you would have encountered the function EnsurePrefix, that takes in a char and a string as arguments; this is one of the members of this class. Aside from this uber useful utility here are a list of what you can also pick up and use inside this sealed class.
| Function/Method | Parameters | Description |
|---|---|---|
| ArrayToString | Array, char | Makes strings out of Arrays |
| Capitalize | string | Uppercases the first letter of a string and lowercases the remaining letters. |
| Clip | string, int, bool | Clips a string at a certain length. The bool argument is for the ellipsis |
| Combine | object, object, string | Combines the ToString() representation of the two objects separated by a string divider |
| Concat | object[] | Accepts a collection of objects and concats the ToString() representation of each value |
| Contains | string, string[] | Looks for the first instance of the string in the string[] object. Returns bool |
| CutUp | string, int | Cuts up the supplied string into the chunk size (int) and returns as an ArrayList |
| Decode | byte[] | Calls the UTF8.GetString(bytes) |
| DecodeMessageParameter | string | Replaces the "_eq_" with "=" and "_qst_" with "?" |
| DictionaryToNameValues | SafeDictionary |
Returns a NameValueCollection from the dictionary object |
| Divide | string, char, bool | Divides the string into two based on the first index of the char separator (if bool = false) or the lastindex if true. Returns string[] |
| DivideAtDigit | string | From the supplied string, the function looks for the first character that is a digit and divides the string from there, returns a string[] |
| Encode | string | Calls UTF8.GetBytes(string) |
| EncodeMessageParameter | string | Replaces the "=" with "_eq_" and "?" with "_qst_" |
| EnsurePostFix | char, string | Ensures that the char value is at the end of the supplied string. If the supplied string is Null or Empty, the function returns the char |
| EnsurePreFix | char, string | Ensures that the char value is at the beginning of the supplied string. If the supplied string is Null or Empty, the function returns the char |
Comments
Post a Comment