UtilString Class

Contains String related utilties.

Definition

Namespace: DevCase.Core.DataProcessing.Common
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
public sealed class UtilString
Inheritance
Object    UtilString

Methods

CalculateStringEntropy Calculates the entropy of a string based on the Shannon's entropy formula.

The entropy is a measure of the amount of uncertainty or randomness in a set of characters.

ConvertFromSuperscript Converts the characters in the input string to their corresponding superscript forms.

Letters in a superscript text are half the normal letter size and are placed above the middle of a text line. For example, the word "Sunshine" in superscript looks like this: "ᔆᵘⁿˢʰⁱⁿᵉ".

Superscripts are often used in mathematics to denote powers of a number, such as "x²" or "yᵐ". They are also often used to write ordinal numbers, for example, 1ˢᵗ, 2ⁿᵈ, 3ʳᵈ, 4ᵗʰ, and so on.

Superscript (Wikipedia): https://en.wikipedia.org/wiki/Subscript_and_superscript

ConvertToSuperscript Converts the characters in the input string to their corresponding superscript forms.

Letters in a superscript text are half the normal letter size and are placed above the middle of a text line. For example, the word "Sunshine" in superscript looks like this: "ᔆᵘⁿˢʰⁱⁿᵉ".

Superscripts are often used in mathematics to denote powers of a number, such as "x²" or "yᵐ". They are also often used to write ordinal numbers, for example, 1ˢᵗ, 2ⁿᵈ, 3ʳᵈ, 4ᵗʰ, and so on.

Superscript (Wikipedia): https://en.wikipedia.org/wiki/Subscript_and_superscript

ConvertToUnicodeLetters(String, UnicodeAlphabeticCharacterSets) Converts the alphabetic characters in the input string to their corresponding Unicode representations based on the specified character set.
ConvertToUnicodeLetters(String, UnicodeAlphanumericCharacterSets) Converts the alphanumeric characters in the input string to their corresponding Unicode representations based on the specified character set.
DrawTextBox Draws a box around the specified text, that is, a text-box.
Equals Determines whether the specified object is equal to the current object.
(Inherited from Object)
FlipTextVertically Transforms the source string into vertical text.
GenerateLoremIpsumText Generates a random 'Lorem Ipsum' paragraph.
GenerateRandomHexString Generates a random hexadecimal string with the specified lenth.
GenerateRandomNumericString Generates a random numeric string with the specified lenth.
GenerateRandomParagraph Generates a random paragraph using the specified set of words.
GenerateRandomString(Int32) Generates a random alpha-numeric string of the specified length.
GenerateRandomString(Char, Int32) Generates a random string of the specified length using the specified characters.
GenerateRandomString(Int32, Int32) Generates a random alpha-numeric string within the specified string-length range.
GenerateRandomString(Char, Int32, Int32) Generates a random string within the specified string-length range using the specified characters.
GenerateTypos Simulate random typographical errors in the input text, based on the specified error rate.

Rules:

● The error-rate percentage calculation is done for the input text length, instead of throwing the dice for each character.

● Letters can only be replaced with different letters of the same case (upper-case or lower-case).

● Numbers can only be replaced with different numbers.

● Special characters like punctuation and white-spaces will remain untouched.

GenerateWhiteSpacedString Generates a white-spaced string with the specified length.
GetDiff Gets the character differences between two strings.
GetDiffCount(String, String) Computes the total amount of differences (insertions, deletions or substitutions) between two strings, by using the Levenshtein algorithm.
GetDiffCount(String, String, Int32) Computes the total amount of differences (insertions, deletions or substitutions) between two strings, by using the Levenshtein algorithm.
GetHashCode Serves as the default hash function.
(Inherited from Object)
GetSimilarity Computes the similarity percentage between two strings, by using the Levenshtein algorithm.
GetType Gets the Type of the current instance.
(Inherited from Object)
JustifyText Justifies the input text by adjusting the line width and spacing between words.
RandomReplaceLetterOrDigit Replaces a letter or digit character with a random character of the same type based on these specific rules:

● If the character is a digit ( Char.IsDigit(character) ), the function returns a different digit from the range "0" to "9".

● If the character is a letter ( Char.IsLetter(character) ):

- If it is a vowel, and it is upper-case, the function returns a different upper-case vowel.

- If it is a vowel, and it is lower-case, the function returns a different lower-case vowel.

- If it is a consonant, and it is upper-case, the function returns a different upper-case consonant.

- If it is a consonant, and it is lower-case, the function returns a different lower-case consonant.

● If the character is neither a letter nor a digit, the function returns the same character.

RandomReplaceLettersAndDigits Replaces letter and digit characters in the source string, with random characters of the same type based on these specific rules:

● If a character is a digit ( Char.IsDigit(character) ), the character is replaced with a different digit from the range "0" to "9".

● If a character is a letter ( Char.IsLetter(character) ):

- If it is a vowel, and it is upper-case, the character is replaced with a different upper-case vowel.

- If it is a vowel, and it is lower-case, the character is replaced with a different lower-case vowel.

- If it is a consonant, and it is upper-case, the character is replaced with a different upper-case consonant.

- If it is a consonant, and it is lower-case, the character is replaced with a different lower-case consonant.

● If a character is neither a letter nor a digit, the character is not replaced.

ToString Returns a string that represents the current object.
(Inherited from Object)
WrapCharacters Decorates the input string by wrapping each character with the specified decorative symbols for its left and right sides.

For example, if the input string is 'ABC', the resulting string could be similar to this: '{A}{B}{C}'.

Extension Methods

CanConvertTo Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
CanConvertToT Determines whether the source object can be converted to the specified target type.
(Defined by ObjectExtensions)
ConvertToT Converts an object to the specified target type.

If the conversion fails, an exception is thrown.
(Defined by ObjectExtensions)

ConvertToT Converts an object to the specified target type.

If the conversion fails, returns the specified default value.
(Defined by ObjectExtensions)

IsDisposable Determines whether the specified object is a disposable type (i.e., it implements IDisposable interface).
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
Speak Speaks the string representation of the source object by using the operating system integrated text-to-speech synthesizer.
(Defined by ObjectExtensions)
ThrowIfNullTException Throws the specified exception if the source object is null.
(Defined by ObjectExtensions)

See Also