Characters that are symbols in this context: UnicodeCategory.MathSymbol
, UnicodeCategory.CurrencySymbol
, UnicodeCategory.ModifierSymbol
and UnicodeCategory.OtherSymbol
from the System.Globalization
namespace. These are the Unicode characters designated Sm, Sc, Sk and So, respectively. All other characters return False
.
From the .Net source:
internal static bool CheckSymbol(UnicodeCategory uc)
{
switch (uc)
{
case UnicodeCategory.MathSymbol:
case UnicodeCategory.CurrencySymbol:
case UnicodeCategory.ModifierSymbol:
case UnicodeCategory.OtherSymbol:
return true;
default:
return false;
}
}
or converted to VB.Net:
Friend Shared Function CheckSymbol(uc As UnicodeCategory) As Boolean
Select Case uc
Case UnicodeCategory.MathSymbol, UnicodeCategory.CurrencySymbol, UnicodeCategory.ModifierSymbol, UnicodeCategory.OtherSymbol
Return True
Case Else
Return False
End Select
End Function
CheckSymbol
is called by IsSymbol
with the Unicode category of the given char.
Since the *
is in the category OtherPunctuation
(you can check this with char.GetUnicodeCategory()
), it is not considered a symbol, and the method correctly returns False
.
To answer your question: use char.GetUnicodeCategory()
to check which category the character falls in, and decide to include it or not in your own logic.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…