Where can I get a list of Unicode chars by class?

后端 未结 5 1830
天命终不由人
天命终不由人 2020-12-13 17:43

I\'m new to learning Unicode, and not sure how much I have to learn based on my ASCII background, but I\'m reading the C# spec on rules for identifiers to determine what cha

5条回答
  •  旧巷少年郎
    2020-12-13 18:35

    You can, of course, use LINQ:

    var charInfo = Enumerable.Range(0, 0x110000)
                             .Where(x => x < 0x00d800 || x > 0x00dfff)
                             .Select(char.ConvertFromUtf32)
                             .GroupBy(s => char.GetUnicodeCategory(s, 0))
                             .ToDictionary(g => g.Key);
    
    foreach (var ch in charInfo[UnicodeCategory.LowercaseLetter])
    {
        Console.Write(ch);
    }
    

    You can find a list of Unicode categories and their short names on MSDN, e.g., "Ll" is short for UnicodeCategory.LowercaseLetter.

提交回复
热议问题