Class CharHelper
- Namespace
- SunamoChar
- Assembly
- SunamoChar.dll
Helper class for character operations including Unicode character detection and string manipulation
public class CharHelper
- Inheritance
-
CharHelper
- Inherited Members
- Extension Methods
Methods
CharWhichIsNotContained(Type, string)
Finds a character constant from type that is not contained in text.
public static string? CharWhichIsNotContained(Type typeAllChars, string text)
Parameters
typeAllCharsTypeThe type containing character constants to search.
textstringThe text to check for character containment.
Returns
- string
The first character constant not found in the text, or null if all are contained.
IsGeneric(char)
Checks if a character is a generic character.
public static bool IsGeneric(char character)
Parameters
charactercharThe character to check.
Returns
- bool
True if the character is a generic character, false otherwise.
IsSpecial(char)
Checks if a character is a special character.
public static bool IsSpecial(char character)
Parameters
charactercharThe character to check.
Returns
- bool
True if the character is a special character, false otherwise.
IsSpecialChar(int, ref string, ref char, bool)
Returns whether the character is whitespace or punctuation.
public static bool IsSpecialChar(int index, ref string text, ref char character, bool isImmediatelyRemoving = false)
Parameters
indexintIndex of the character to check in the text.
textstringThe text containing the character.
charactercharOutput parameter for the character at the specified index.
isImmediatelyRemovingboolWhether to immediately remove the character from text if it is special.
Returns
- bool
True if the character at the specified index is a special character, false otherwise.
IsUnicodeChar(UnicodeChars, char)
Checks if a character matches the specified Unicode character type
public static bool IsUnicodeChar(UnicodeChars unicodeCharType, char character)
Parameters
unicodeCharTypeUnicodeCharsThe Unicode character type to check against.
charactercharThe character to check.
Returns
- bool
True if the character matches the specified type, false otherwise.
IsUnicodeChar(char)
Determines the Unicode character type of a character.
public static UnicodeChars IsUnicodeChar(char character)
Parameters
charactercharThe character to classify.
Returns
- UnicodeChars
The Unicode character type category of the specified character.
OnlyAccepted(string, List<Func<char, bool>>, bool)
Returns only characters that match any of the predicates.
public static string OnlyAccepted(string text, List<Func<char, bool>> predicates, bool isNegating = false)
Parameters
textstringThe text to filter.
predicatesList<Func<char, bool>>List of functions to test each character.
isNegatingboolWhether to negate the predicate results.
Returns
- string
String containing only the characters that match any of the predicates.
OnlyAccepted(string, Func<char, bool>, bool)
Returns only characters that match the predicate.
public static string OnlyAccepted(string text, Func<char, bool> predicate, bool isNegating = false)
Parameters
textstringThe text to filter.
predicateFunc<char, bool>Function to test each character.
isNegatingboolWhether to negate the predicate result.
Returns
- string
String containing only the characters that match the predicate.
OnlyDigits(string)
Returns only digit characters from text.
public static string OnlyDigits(string text)
Parameters
textstringThe text to extract digits from.
Returns
- string
String containing only the digit characters from the input text.
SplitSpecial(string, params char[])
Splits text by special delimiters, removing empty entries.
public static List<string> SplitSpecial(string text, params char[] delimiters)
Parameters
Returns
SplitSpecialNone(string, params char[])
Splits text by special delimiters, keeping empty entries.
public static List<string> SplitSpecialNone(string text, params char[] delimiters)
Parameters
Returns
TypesOfUnicodeChars(string)
Returns list of distinct Unicode character types found in text.
public static List<UnicodeChars> TypesOfUnicodeChars(string text)
Parameters
textstringThe text to analyze for Unicode character types.
Returns
- List<UnicodeChars>
List of distinct Unicode character type categories found in the text.