Class StringUtilities
Defines utilities related to System.
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.Core
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public static class StringUtilities
Methods
DetermineCasing(String)
Determines the casing as in String
Declaration
public static StringUtilities.Casing DetermineCasing(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s | The input string (must not be null) |
Returns
Type | Description |
---|---|
String |
EndsWithAny(String, Char[])
Returns true
if the string s
ends with any
of the characters in characterList
, and false
otherwise.
Declaration
public static bool EndsWithAny(string s, char[] characterList)
Parameters
Type | Name | Description |
---|---|---|
String | s | |
Char[] | characterList |
Returns
Type | Description |
---|---|
Boolean |
EscapeString(String)
Escapes all double quotes and backslashes in a string.
Declaration
public static string EscapeString(string s)
Parameters
Type | Name | Description |
---|---|---|
String | s | The input string. |
Returns
Type | Description |
---|---|
String | The string where all double quotes will be prefixed with a backslash. |
EscapeString(String, String)
Escapes special characters in a string, prefixing them with a backslash.
Declaration
public static string EscapeString(string s, string charactersToEscape)
Parameters
Type | Name | Description |
---|---|---|
String | s | The input string. |
String | charactersToEscape | The characters to escape |
Returns
Type | Description |
---|---|
String | The string where all occurrences of any of the characters to escape are prefixed with a backslash. |
FullWidthToHalfWidth(String)
Perform full-width to half-width conversion
Declaration
public static string FullWidthToHalfWidth(string input)
Parameters
Type | Name | Description |
---|---|---|
String | input |
Returns
Type | Description |
---|---|
String |
GenerateRandomWord(Int32, Boolean)
Generates a string which consists of random letters in the range [a-z] with the specified length.
Declaration
public static string GenerateRandomWord(int length, bool initialUpper)
Parameters
Type | Name | Description |
---|---|---|
Int32 | length | The length of the string to be generated. |
Boolean | initialUpper | If true, the initial letter of the generated string will be converted to upper-case. If false, the initial letter will remain lower-case. |
Returns
Type | Description |
---|---|
String | A string which consists of a random sequence of letters [a-z] with the specified length. |
GetPrefixLength(String, Char[])
Computes the length of the prefix of s
which entirely consists
of characters in prefixChars
. If either of the parameters is
null
or empty, 0
is returned.
Declaration
public static int GetPrefixLength(string s, char[] prefixChars)
Parameters
Type | Name | Description |
---|---|---|
String | s | The string |
Char[] | prefixChars | The set of prefix characters |
Returns
Type | Description |
---|---|
Int32 | The length of the prefix of |
GetSuffixLength(String, Char[])
Computes the length of the suffix of s
which entirely consists
of characters in suffixChars
. If either of the parameters is
null
or empty, 0
is returned.
Declaration
public static int GetSuffixLength(string s, char[] suffixChars)
Parameters
Type | Name | Description |
---|---|---|
String | s | The string |
Char[] | suffixChars | The set of suffix characters |
Returns
Type | Description |
---|---|
Int32 | The length of the suffix of |
HalfWidthToFullWidth(String)
Converts half-width characters to full-width characters
Declaration
public static string HalfWidthToFullWidth(string input)
Parameters
Type | Name | Description |
---|---|---|
String | input | single byte string, halfwidth string |
Returns
Type | Description |
---|---|
String |
HalfWidthToFullWidth2(String)
Unlike Half
Declaration
public static string HalfWidthToFullWidth2(string input)
Parameters
Type | Name | Description |
---|---|---|
String | input |
Returns
Type | Description |
---|---|
String |
IsAllWhitespace(String)
Returns true if t
contains only whitespace characters (Is
Declaration
public static bool IsAllWhitespace(string t)
Parameters
Type | Name | Description |
---|---|---|
String | t |
Returns
Type | Description |
---|---|
Boolean |
MergeStrings(String, String)
Appends each individual charater of b
to a
, if it is not
already present, and returns the result. If a
already contains
duplicates, they are kept.
Declaration
public static string MergeStrings(string a, string b)
Parameters
Type | Name | Description |
---|---|---|
String | a | The first string |
String | b | The second string |
Returns
Type | Description |
---|---|
String | A string which consists of the input string |
RemoveAll(String, Predicate<Char>)
Computes a copy of s
in which all characters which
satisfy property
are removed.
Declaration
public static string RemoveAll(string s, Predicate<char> property)
Parameters
Type | Name | Description |
---|---|---|
String | s | The input string |
Predicate<Char> | property | The character property to test |
Returns
Type | Description |
---|---|
String |
StartWithAny(String, Char[])
Returns true
if the string s
starts with any
of the characters in characterList
, and false
otherwise.
Declaration
public static bool StartWithAny(string s, char[] characterList)
Parameters
Type | Name | Description |
---|---|---|
String | s | |
Char[] | characterList |
Returns
Type | Description |
---|---|
Boolean |
TrimEnd(String, Char[], out String)
Trims off any character contained in the trimCharacters
from the
end of the specified string s
, and returns the remainder, as well
as the trimmed-off suffix in trimmedSuffix
. If either s
or trimCharacters
are null
or empty, the result will be equal
to s
and trimmedSuffix
will be null.
Declaration
public static string TrimEnd(string s, char[] trimCharacters, out string trimmedSuffix)
Parameters
Type | Name | Description |
---|---|---|
String | s | The input string |
Char[] | trimCharacters | The set of characters to trim off at the start of |
String | trimmedSuffix | If any characters have been trimmed off, this out parameter will
contain the trimmed-off suffix. If no characters have been trimmed off, this out parameter will
be |
Returns
Type | Description |
---|---|
String | The remainder of |
TrimStart(String, Char[], out String)
Trims off any character contained in the trimCharacters
from the
start of the specified string s
, and returns the remainder, as well
as the trimmed-off prefix in trimmedPrefix
. If either s
or trimCharacters
are null
or empty, the result will be equal
to s
and trimmedPrefix
will be null.
Declaration
public static string TrimStart(string s, char[] trimCharacters, out string trimmedPrefix)
Parameters
Type | Name | Description |
---|---|---|
String | s | The input string |
Char[] | trimCharacters | The set of characters to trim off at the start of |
String | trimmedPrefix | If any characters have been trimmed off, this out parameter will
contain the trimmed-off prefix. If no characters have been trimmed off, this out parameter will
be |
Returns
Type | Description |
---|---|
String | The remainder of |