def CaseGroups(unicode_dir=_UNICODE_DIR):
  """Returns list of Unicode code groups equivalent under case folding.

  Each group is a sorted list of code points,
  and the list of groups is sorted by first code point
  in the group.

  Args:
    unicode_dir: Unicode data directory

  Returns:
    list of Unicode code groups
  """

  # Dict mapping lowercase code point to fold-equivalent group.
  togroup = {}

  def DoLine(codes, fields):
    """Process single CaseFolding.txt line, updating togroup."""
    (_, foldtype, lower, _) = fields
    if foldtype not in ("C", "S"):
      return
    lower = _UInt(lower)
    togroup.setdefault(lower, [lower]).extend(codes)

  ReadUnicodeTable(unicode_dir+"/CaseFolding.txt", 4, DoLine)

  groups = togroup.values()
  for g in groups:
    g.sort()
  groups.sort()
  return togroup, groups
def CaseGroups ( unicode_dir = _UNICODE_DIR ) : togroup = { } def DoLine ( codes , fields ) : ( _ , foldtype , lower , _ ) = fields if foldtype not in ( "C" , "S" ) : return lower = _UInt ( lower ) togroup . setdefault ( lower , [ lower ] ) . extend ( codes ) ReadUnicodeTable ( unicode_dir + "/CaseFolding.txt" , 4 , DoLine ) groups = togroup . values ( ) for g in groups : g . sort ( ) groups . sort ( ) return togroup , groups
Returns list of Unicode code groups equivalent under case folding.

  Each group is a sorted list of code points,
  and the list of groups is sorted by first code point
  in the group.

  Args:
    unicode_dir: Unicode data directory

  Returns:
    list of Unicode code groups