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 |
---|---|---|
System. |
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 |
---|---|---|
System. |
s | |
System. |
characterList |
Returns
Type | Description |
---|---|
System. |
EscapeString(String)
Escapes all double quotes and backslashes in a string.
Declaration
public static string EscapeString(string s)
Parameters
Type | Name | Description |
---|---|---|
System. |
s | The input string. |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
System. |
s | The input string. |
System. |
charactersToEscape | The characters to escape |
Returns
Type | Description |
---|---|
System. |
The string where all occurrences of any of the characters to escape are prefixed with a backslash. |
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 |
---|---|---|
System. |
length | The length of the string to be generated. |
System. |
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 |
---|---|
System. |
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 |
---|---|---|
System. |
s | The string |
System. |
prefixChars | The set of prefix characters |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
System. |
s | The string |
System. |
suffixChars | The set of suffix characters |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
System. |
input | single byte string, halfwidth string |
Returns
Type | Description |
---|---|
System. |
HalfWidthToFullWidth2(String)
Unlike Half
Declaration
public static string HalfWidthToFullWidth2(string input)
Parameters
Type | Name | Description |
---|---|---|
System. |
input |
Returns
Type | Description |
---|---|
System. |
IsAllWhitespace(String)
Returns true if t
contains only whitespace characters (Is
Declaration
public static bool IsAllWhitespace(string t)
Parameters
Type | Name | Description |
---|---|---|
System. |
t |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
System. |
a | The first string |
System. |
b | The second string |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
System. |
s | The input string |
System. |
property | The character property to test |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
System. |
s | |
System. |
characterList |
Returns
Type | Description |
---|---|
System. |
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 |
---|---|---|
System. |
s | The input string |
System. |
trimCharacters | The set of characters to trim off at the start of |
System. |
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 |
---|---|
System. |
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 |
---|---|---|
System. |
s | The input string |
System. |
trimCharacters | The set of characters to trim off at the start of |
System. |
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 |
---|---|
System. |
The remainder of |