本文整理汇总了C#中UnicodeCategory类的典型用法代码示例。如果您正苦于以下问题:C# UnicodeCategory类的具体用法?C# UnicodeCategory怎么用?C# UnicodeCategory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnicodeCategory类属于命名空间,在下文中一共展示了UnicodeCategory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetUnicodeCategory
public void GetUnicodeCategory(string s, UnicodeCategory[] expected)
{
for (int i = 0; i < expected.Length; i++)
{
Assert.Equal(expected[i], CharUnicodeInfo.GetUnicodeCategory(s, i));
}
}
示例2: Charset
internal Charset(UnicodeCategory cat)
{
m_cat = cat;
for (m_generic=char.MinValue;Char.GetUnicodeCategory(m_generic)!=cat;m_generic++)
;
m_chars[m_generic] = true;
}
示例3: Filter
public static string Filter(this string value, FilterAction matchRule, UnicodeCategory categories)
{
return new string((from c in value
where matchRule == FilterAction.Keep
? categories.HasFlag(Char.GetUnicodeCategory(c))
: !categories.HasFlag(Char.GetUnicodeCategory(c))
select c).ToArray());
}
示例4: OnDeserialized
private void OnDeserialized(StreamingContext ctx)
{
this.strLen = this.endIndex + 1;
this.currTextElementLen = this.nextTextElementLen;
if (this.charLen == -1)
{
this.uc = CharUnicodeInfo.InternalGetUnicodeCategory(this.str, this.index, out this.charLen);
}
}
示例5: YyLexer
public YyLexer(ErrorHandler eh)
{
erh = eh;
#if (GENTIME)
UsingCat(UnicodeCategory.OtherPunctuation);
m_gencat = UnicodeCategory.OtherPunctuation;
#endif
new Tfactory(this,"TOKEN",new TCreator(Tokenfactory));
}
示例6: OnDeserialized
private void OnDeserialized(StreamingContext ctx)
{
strLen = endIndex + 1;
currTextElementLen = nextTextElementLen;
if (charLen == -1)
{
uc = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out charLen);
}
}
示例7: OnDeserialized
private void OnDeserialized(StreamingContext ctx)
{
_strLen = _endIndex + 1;
_currTextElementLen = _nextTextElementLen;
if (_charLen == -1)
{
_uc = CharUnicodeInfo.InternalGetUnicodeCategory(_str, _index, out _charLen);
}
}
示例8: IsLetter_Char
public static void IsLetter_Char()
{
var categories = new UnicodeCategory[]
{
UnicodeCategory.UppercaseLetter,
UnicodeCategory.LowercaseLetter,
UnicodeCategory.TitlecaseLetter,
UnicodeCategory.ModifierLetter,
UnicodeCategory.OtherLetter
};
foreach (char c in GetTestChars(categories))
Assert.True(char.IsLetter(c));
foreach (char c in GetTestCharsNotInCategory(categories))
Assert.False(char.IsLetter(c));
}
示例9: IsLetterCategory
private bool IsLetterCategory(UnicodeCategory uc) {
return (uc == UnicodeCategory.UppercaseLetter
|| uc == UnicodeCategory.LowercaseLetter
|| uc == UnicodeCategory.TitlecaseLetter
|| uc == UnicodeCategory.ModifierLetter
|| uc == UnicodeCategory.OtherLetter);
}
示例10: IsWordSeparator
/* false */ (0 << 29); // OtherNotAssigned = 29;
private bool IsWordSeparator(UnicodeCategory category) {
return (wordSeparatorMask & (1 << (int)category)) != 0;
}
示例11: IsCombiningCategory
internal static bool IsCombiningCategory(UnicodeCategory uc) {
Contract.Assert(uc >= 0, "uc >= 0");
return (
uc == UnicodeCategory.NonSpacingMark ||
uc == UnicodeCategory.SpacingCombiningMark ||
uc == UnicodeCategory.EnclosingMark
);
}
示例12: IsWhiteSpace_String_Int
public static void IsWhiteSpace_String_Int()
{
var categories = new UnicodeCategory[]
{
UnicodeCategory.SpaceSeparator,
UnicodeCategory.LineSeparator,
UnicodeCategory.ParagraphSeparator
};
foreach (char c in GetTestChars(categories))
Assert.True(char.IsWhiteSpace(c.ToString(), 0));
// Some control chars are also considered whitespace for legacy reasons.
// if ((c >= '\x0009' && c <= '\x000d') || c == '\x0085')
Assert.True(char.IsWhiteSpace("\u000b", 0));
Assert.True(char.IsWhiteSpace("\u0085", 0));
foreach (char c in GetTestCharsNotInCategory(categories))
{
// Need to special case some control chars that are treated as whitespace
if ((c >= '\x0009' && c <= '\x000d') || c == '\x0085') continue;
Assert.False(char.IsWhiteSpace(c.ToString(), 0));
}
}
示例13: IsSymbol_String_Int
public static void IsSymbol_String_Int()
{
var categories = new UnicodeCategory[]
{
UnicodeCategory.MathSymbol,
UnicodeCategory.ModifierSymbol,
UnicodeCategory.CurrencySymbol,
UnicodeCategory.OtherSymbol
};
foreach (char c in GetTestChars(categories))
Assert.True(char.IsSymbol(c.ToString(), 0));
foreach (char c in GetTestCharsNotInCategory(categories))
Assert.False(char.IsSymbol(c.ToString(), 0));
}
示例14: IsPunctuation_String_Int
public static void IsPunctuation_String_Int()
{
var categories = new UnicodeCategory[]
{
UnicodeCategory.ConnectorPunctuation,
UnicodeCategory.DashPunctuation,
UnicodeCategory.OpenPunctuation,
UnicodeCategory.ClosePunctuation,
UnicodeCategory.InitialQuotePunctuation,
UnicodeCategory.FinalQuotePunctuation,
UnicodeCategory.OtherPunctuation
};
foreach (char c in GetTestChars(categories))
Assert.True(char.IsPunctuation(c.ToString(), 0));
foreach (char c in GetTestCharsNotInCategory(categories))
Assert.False(char.IsPunctuation(c.ToString(), 0));
}
示例15: IsLetterOrDigit_String_Int
public static void IsLetterOrDigit_String_Int()
{
var categories = new UnicodeCategory[]
{
UnicodeCategory.UppercaseLetter,
UnicodeCategory.LowercaseLetter,
UnicodeCategory.TitlecaseLetter,
UnicodeCategory.ModifierLetter,
UnicodeCategory.OtherLetter,
UnicodeCategory.DecimalDigitNumber
};
foreach (char c in GetTestChars(categories))
Assert.True(char.IsLetterOrDigit(c.ToString(), 0));
foreach (char c in GetTestCharsNotInCategory(categories))
Assert.False(char.IsLetterOrDigit(c.ToString(), 0));
}