在.Net中,给定一个字符,有没有办法判断该字符是否属于某个特定Unicode类别?我感兴趣的类别在这里定义http://www.fileformat.info/info/unicode/category/index.htm
例如,有没有这样的函数?:
bool isCharInClass(Char c, String class)这可以被称为:
SomeClass.isCharInClass("a", "Lo");发布于 2011-11-28 09:41:27
您可以使用Char.GetUnicodeCategory或CharUnicodeInfo.GetUnicodeCategory来获取unicode类别(作为UnicodeCategory)。
发布于 2011-11-28 09:52:07
使用System.Globalization命名空间
Console.WriteLine("{0} , {1}", 'a', CharUnicodeInfo.GetUnicodeCategory('a'));
Console.WriteLine("{0} , {1}", 'A', CharUnicodeInfo.GetUnicodeCategory('A'));
Console.WriteLine("{0} , {1}", '1', CharUnicodeInfo.GetUnicodeCategory('1'));
Console.WriteLine("{0} , {1}", '$', CharUnicodeInfo.GetUnicodeCategory('$'));您可以从获取更多文档
https://stackoverflow.com/questions/8290661
复制相似问题