Class CharacterProperties
Proides methods that check for certain properties of strings and characters.
Inheritance
Inherited Members
Namespace: Sdl.LanguagePlatform.Core
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 |
|---|---|
| System.Char[] |
WhitespaceCharacters
Contains a set of known whitespace characters from different languages. This should
be equivalent to the set of characters for which System.Char.IsWhiteSpace(System.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 |
|---|---|
| System.Char[] |
Properties
UppercaseCharacters
Gets a collection of all characters in the range [U+0020, U+00FB] for which
System.Char.IsUpper(System.Char) is true.
Declaration
public static char[] UppercaseCharacters { get; }
Property Value
| Type | Description |
|---|---|
| System.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 |
|---|---|---|
| System.Char | c |
Returns
| Type | Description |
|---|---|
| CharacterProperties.Case |
GetCase(String)
Determines the case of the string, if it is consistent.
Declaration
public static CharacterProperties.Case GetCase(string s)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | s |
Returns
| Type | Description |
|---|---|
| CharacterProperties.Case |
GetCase(String, Int32)
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 |
|---|---|---|
| System.String | s | |
| System.Int32 | length |
Returns
| Type | Description |
|---|---|
| CharacterProperties.Case |
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 |
|---|---|---|
| System.String | s | |
| System.Predicate<System.Char> | predicate |
Returns
| Type | Description |
|---|---|
| System.Int32 |
GetUnicodeBlock(Char)
Attempts to identify the UnicodeBlock for the provided character.
Declaration
public static UnicodeBlock GetUnicodeBlock(char c)
Parameters
| Type | Name | Description |
|---|---|---|
| System.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 System.Globalization.UnicodeCategory. The lookup is case-insensitive.
Declaration
public static UnicodeCategory? GetUnicodeCategoryFromName(string className)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | className | The category name |
Returns
| Type | Description |
|---|---|
| System.Nullable<System.Globalization.UnicodeCategory> | The corresponding System.Globalization.UnicodeCategory, or
|
GetUnicodeCategoryName(UnicodeCategory)
Maps from System.Globalization.UnicodeCategory to class names as they are used in CharacterSets.
Declaration
public static string GetUnicodeCategoryName(UnicodeCategory cat)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Globalization.UnicodeCategory | cat | The Unicode category |
Returns
| Type | Description |
|---|---|
| System.String | A category name, to be used in character sets. |
IsAll(String, Int32, 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 |
|---|---|---|
| System.String | s | |
| System.Int32 | start | |
| System.Predicate<System.Char> | predicate |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.String | s | |
| System.Predicate<System.Char> | predicate |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c |
Returns
| Type | Description |
|---|---|
| System.Boolean | true if |
IsClosingBracket(Char)
Determines whether the specified character is a closing bracket.
Declaration
public static bool IsClosingBracket(char c)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | A character |
| UnicodeBlock | b |
Returns
| Type | Description |
|---|---|
| System.Boolean |
|
IsJaLongVowelMarker(Char)
Tests whether c is the JA long vowel marker
Declaration
public static bool IsJaLongVowelMarker(char c)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char | c |
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsKoreanChar(Char)
Tests whether c is a Hangul character, precomposed or otherwise
Declaration
public static bool IsKoreanChar(char c)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char | c |
Returns
| Type | Description |
|---|---|
| System.Boolean |
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 |
|---|---|---|
| System.Char | c |
Returns
| Type | Description |
|---|---|
| System.Boolean |
IsOpeningBracket(Char)
Determines whether the specified character is an opening bracket.
Declaration
public static bool IsOpeningBracket(char c)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The characters. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.String | s | The string. |
| System.Globalization.UnicodeCategory | c | The Unicode category. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c |
Returns
| Type | Description |
|---|---|
| System.Boolean |
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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The character. |
Returns
| Type | Description |
|---|---|
| System.Boolean | 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 |
|---|---|---|
| System.Char | c | The input character. |
Returns
| Type | Description |
|---|---|
| System.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 |
|---|---|---|
| System.String | s | The input string. |
Returns
| Type | Description |
|---|---|
| System.String | The normalized string. |
ToBase(String, Boolean)
See ToBase(String)
Declaration
public static string ToBase(string s, bool skipSurrogates)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | s | |
| System.Boolean | skipSurrogates | If true, no changes will be applied if any surrogate-pair bytes are found after decomposition |
Returns
| Type | Description |
|---|---|
| System.String |
ToCase(Char, CharacterProperties.Case)
Applies the specified casing to the provided character.
Declaration
public static char ToCase(char ch, CharacterProperties.Case c)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Char | ch | |
| CharacterProperties.Case | c |
Returns
| Type | Description |
|---|---|
| System.Char |
ToCase(String, CharacterProperties.Case)
Applies the specified casing to the provided string.
Declaration
public static string ToCase(string s, CharacterProperties.Case c)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | s | |
| CharacterProperties.Case | c |
Returns
| Type | Description |
|---|---|
| System.String |