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