Class CharacterProperties
Proides methods that check for certain properties of strings and characters.
Inherited Members
Namespace: SdlSdl.LanguagePlatformCore
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
public static class CharacterProperties
Fields
Blanks
Contains a set of known blank characters of various widths from different languages. This should be a subset of WhitespaceCharacters.
Declaration
public static readonly char[] Blanks
Field Value
Type | Description |
---|---|
char |
WhitespaceCharacters
Contains a set of known whitespace characters from different languages. This should
be equivalent to the set of characters for which IsWhiteSpace(char) returns
true
, which however is incomplete in earlier .Net versions.
The elements of the array are sorted in ascending order, so binary search can be used.
Declaration
public static readonly char[] WhitespaceCharacters
Field Value
Type | Description |
---|---|
char |
Properties
UppercaseCharacters
Gets a collection of all characters in the range [U+0020, U+00FB] for which
IsUpper(char) is true
.
Declaration
public static char[] UppercaseCharacters { get; }
Property Value
Type | Description |
---|---|
char |
Methods
GetCase(char)
Determines the case of a character. Only upper and lower case characters are distinguished, in all other cases or for non-letter characters, Other is returned.
Declaration
public static CharacterProperties.Case GetCase(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c |
Returns
Type | Description |
---|---|
CharacterPropertiesCase |
GetCase(string)
Determines the case of the string, if it is consistent.
Declaration
public static CharacterProperties.Case GetCase(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s |
Returns
Type | Description |
---|---|
CharacterPropertiesCase |
GetCase(string, int)
Determines the case of the string, if it is consistent. The string is only scanned up to the specified length.
Declaration
public static CharacterProperties.Case GetCase(string s, int length)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
int | length |
Returns
Type | Description |
---|---|
CharacterPropertiesCase |
GetPrefixLength(string, Predicate<char>)
Computes and returns the length of the prefix of the provided string s
where each
character satisfies the provided predicate.
Declaration
public static int GetPrefixLength(string s, Predicate<char> predicate)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
Predicatechar | predicate |
Returns
Type | Description |
---|---|
int |
GetUnicodeBlock(char)
Attempts to identify the UnicodeBlock for the provided character.
Declaration
public static UnicodeBlock GetUnicodeBlock(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | A character to get the UnicodeBlock for. |
Returns
Type | Description |
---|---|
UnicodeBlock | The UnicodeBlock for |
GetUnicodeCategoryFromName(string)
Maps Unicode category names as they are used in CharacterSets to the corresponding UnicodeCategory. The lookup is case-insensitive.
Declaration
public static UnicodeCategory? GetUnicodeCategoryFromName(string className)
Parameters
Type | Name | Description |
---|---|---|
string | className | The category name |
Returns
Type | Description |
---|---|
UnicodeCategory | The corresponding UnicodeCategory, or
|
GetUnicodeCategoryName(UnicodeCategory)
Maps from UnicodeCategory to class names as they are used in CharacterSets.
Declaration
public static string GetUnicodeCategoryName(UnicodeCategory cat)
Parameters
Type | Name | Description |
---|---|---|
UnicodeCategory | cat | The Unicode category |
Returns
Type | Description |
---|---|
string | A category name, to be used in character sets. |
IsAll(string, int, Predicate<char>)
Evaluates the predicate on all characters in the string, starting from position start
,
and returns true if all characters
fulfill the predicate, and false otherwise. Note that the method will always return true
for the empty string or if the start position exceeds the string length.
Declaration
public static bool IsAll(string s, int start, Predicate<char> predicate)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
int | start | |
Predicatechar | predicate |
Returns
Type | Description |
---|---|
bool | true if all characters fulfill the predicate, or |
IsAll(string, Predicate<char>)
Evaluates the predicate on all characters in the string and returns true if all characters
fulfill the predicate, and false otherwise. Note that the method will always return true
for the empty string.
Declaration
public static bool IsAll(string s, Predicate<char> predicate)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
Predicatechar | predicate |
Returns
Type | Description |
---|---|
bool | true if all characters fulfill the predicate or |
IsApostrophe(char)
Determines whether the specified character is an apostrophe.
Declaration
public static bool IsApostrophe(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is an apostrophe, otherwise false. |
IsBlank(char)
Determines whether the specified character is a blank.
This test does not cover format characters.
Declaration
public static bool IsBlank(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a blank, otherwise false. |
IsBrace(char)
Determines whether the specified character is a brace.
Declaration
public static bool IsBrace(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a brace, otherwise false. |
IsBracket(char)
Determines whether the specified character is an opening or a closing bracket.
Declaration
public static bool IsBracket(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is an opening or a closing bracket, otherwise false. |
IsCJKChar(char)
Tests whether c
is a CJK (Chinese/Japanese/Korean) character - note, this does NOT include modern Korean characters
Declaration
public static bool IsCJKChar(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c |
Returns
Type | Description |
---|---|
bool | true if |
Remarks
Regarding Korean, the character ranges covered include (not necessarily all) the largely-archaic Hanja characters. To test for Hangul characters, use IsKoreanChar(char)
IsCJKPunctuation(char)
Tests whether the provided character c
is a CJK (Chinese/Japanese/Korean) punctuation characater.
Declaration
public static bool IsCJKPunctuation(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c |
Returns
Type | Description |
---|---|
bool | true if |
IsClosingBracket(char)
Determines whether the specified character is a closing bracket.
Declaration
public static bool IsClosingBracket(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a closing bracket, otherwise false. |
IsClosingParenthesis(char)
Determines whether the specified character is a closing paranthesis.
Declaration
public static bool IsClosingParenthesis(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a closing paranthesis, otherwise false. |
IsClosingQuote(char)
Determines whether the specified character is a closing quote.
Declaration
public static bool IsClosingQuote(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a closing quote, otherwise false. |
IsColon(char)
Determines whether the specified character is a colon.
Declaration
public static bool IsColon(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a colon, otherwise false. |
IsComma(char)
Determines whether the specified character is a comma.
Declaration
public static bool IsComma(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a comma, otherwise false. |
IsDash(char)
Determines whether the specified character is a dash.
Declaration
public static bool IsDash(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a dash, otherwise false. |
IsDot(char)
Determines whether the specified character is a dor.
Declaration
public static bool IsDot(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a dot, otherwise false. |
IsDoubleQuote(char)
Determines whether the specified character is a double quote.
Declaration
public static bool IsDoubleQuote(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a double quote, otherwise false. |
IsExclamation(char)
Determines whether the specified character is an exclamation mark.
Declaration
public static bool IsExclamation(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is an exclamation mark, otherwise false. |
IsHyphen(char)
Determines whether the specified character is a hyphen.
Declaration
public static bool IsHyphen(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a hyphen, otherwise false. |
IsInBlock(char, UnicodeBlock)
Tests whether c
is contained in the UnicodeBlock b
.
Declaration
public static bool IsInBlock(char c, UnicodeBlock b)
Parameters
Type | Name | Description |
---|---|---|
char | c | A character |
UnicodeBlock | b |
Returns
Type | Description |
---|---|
bool |
|
IsJaLongVowelMarker(char)
Tests whether c
is the JA long vowel marker
Declaration
public static bool IsJaLongVowelMarker(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c |
Returns
Type | Description |
---|---|
bool |
IsKoreanChar(char)
Tests whether c
is a Hangul character, precomposed or otherwise
Declaration
public static bool IsKoreanChar(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c |
Returns
Type | Description |
---|---|
bool |
IsLatinLetter(char)
Determines whether the specified character is a Latin-alphabet letter, single or double width
Declaration
public static bool IsLatinLetter(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c |
Returns
Type | Description |
---|---|
bool |
IsOpeningBracket(char)
Determines whether the specified character is an opening bracket.
Declaration
public static bool IsOpeningBracket(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is an opening bracket, otherwise false. |
IsOpeningParenthesis(char)
Determines whether the specified character is an opening paranthesis.
Declaration
public static bool IsOpeningParenthesis(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is an openint paranthesis, otherwise false. |
IsOpeningQuote(char)
Determines whether the specified character is an opening quote.
Declaration
public static bool IsOpeningQuote(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is an opening quote, otherwise false. |
IsParagraph(char)
Determines whether the specified character is a paragraph separator.
Declaration
public static bool IsParagraph(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a paragraph separator, otherwise false. |
IsParenthesis(char)
Determines whether the specified character is an opening or a closing paranthesis.
Declaration
public static bool IsParenthesis(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is an opening or a closing , otherwise false. |
IsPercent(char)
Determines whether the specified character is a percent character.
Declaration
public static bool IsPercent(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a percent character, otherwise false. |
IsQuestion(char)
Determines whether the specified character is a question mark.
Declaration
public static bool IsQuestion(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The characters. |
Returns
Type | Description |
---|---|
bool | true if c is a question mark, otherwise false. |
IsQuote(char)
Determines whether the specified character is a quote.
Declaration
public static bool IsQuote(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a quote, otherwise false. |
IsSemicolon(char)
Determines whether the specified character is a semicolon.
Declaration
public static bool IsSemicolon(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a semicolon, otherwise false. |
IsSequenceOf(string, UnicodeCategory)
Determines whether the specified string is a sequence of characters of the specified unicode category c
.
Declaration
public static bool IsSequenceOf(string s, UnicodeCategory c)
Parameters
Type | Name | Description |
---|---|---|
string | s | The string. |
UnicodeCategory | c | The Unicode category. |
Returns
Type | Description |
---|---|
bool | true if all the characters in |
IsSingleQuote(char)
Determines whether the specified character is a single quote.
Declaration
public static bool IsSingleQuote(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a single quote, otherwise false. |
IsStop(char)
Determines whether the specified character is a stop character such as colon, dot, exclamation mark, question mark or semicolon.
Declaration
public static bool IsStop(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a stop character, otherwise false. |
IsSurrounder(char)
Determines whether the specified character is any of the known surrounder characters, such as bracket, paranthesis, quote, apostrophe or a special surrounder.
Declaration
public static bool IsSurrounder(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a any of the surrounder characters, otherwise false. |
IsTabulator(char)
Determines whether the specified character is a tabulator.
Declaration
public static bool IsTabulator(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a tabulator, otherwise false. |
IsUpperOrLower(char)
Returns true if c
is upper or lower case, and false otherwise.
Declaration
public static bool IsUpperOrLower(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c |
Returns
Type | Description |
---|---|
bool |
IsVowel(char)
Determines whether the specified character is a vowel (Western or Far East).
Declaration
public static bool IsVowel(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a vowel, otherwise false. |
IsWhitespace(char)
Determines whether the specified character is a whitespace.
This test does not cover format characters.
Declaration
public static bool IsWhitespace(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The character. |
Returns
Type | Description |
---|---|
bool | true if c is a whitespace, otherwise false. |
ToBase(char)
Returns a new character which is the normalized version of the input character, using full canonical decomposition.
Declaration
public static char ToBase(char c)
Parameters
Type | Name | Description |
---|---|---|
char | c | The input character. |
Returns
Type | Description |
---|---|
char | The normalized character. |
ToBase(string)
Returns a new string with the same textual value as the input string, but whose binary representation is normalized using full canonical decomposition ignoring any characters that belong to the following Unicode categories: Format, ModifierLetter, NonSpacingMark, OtherNotAssigned, ParagraphSeparator, PrivateUse, SpaceSeparator, SpacingCombiningMark.
Declaration
public static string ToBase(string s)
Parameters
Type | Name | Description |
---|---|---|
string | s | The input string. |
Returns
Type | Description |
---|---|
string | The normalized string. |
ToBase(string, bool)
See ToBase(string)
Declaration
public static string ToBase(string s, bool skipSurrogates)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
bool | skipSurrogates | If true, no changes will be applied if any surrogate-pair bytes are found after decomposition |
Returns
Type | Description |
---|---|
string |
ToCase(char, Case)
Applies the specified casing to the provided character.
Declaration
public static char ToCase(char ch, CharacterProperties.Case c)
Parameters
Type | Name | Description |
---|---|---|
char | ch | |
CharacterPropertiesCase | c |
Returns
Type | Description |
---|---|
char |
ToCase(string, Case)
Applies the specified casing to the provided string.
Declaration
public static string ToCase(string s, CharacterProperties.Case c)
Parameters
Type | Name | Description |
---|---|---|
string | s | |
CharacterPropertiesCase | c |
Returns
Type | Description |
---|---|
string |