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
(unicode_dir=_UNICODE_DIR)
| 223 | |
| 224 | |
| 225 | def CaseGroups(unicode_dir=_UNICODE_DIR): |
| 226 | """Returns list of Unicode code groups equivalent under case folding. |
| 227 | |
| 228 | Each group is a sorted list of code points, |
| 229 | and the list of groups is sorted by first code point |
| 230 | in the group. |
| 231 | |
| 232 | Args: |
| 233 | unicode_dir: Unicode data directory |
| 234 | |
| 235 | Returns: |
| 236 | list of Unicode code groups |
| 237 | """ |
| 238 | |
| 239 | # Dict mapping lowercase code point to fold-equivalent group. |
| 240 | togroup = {} |
| 241 | |
| 242 | def DoLine(codes, fields): |
| 243 | """Process single CaseFolding.txt line, updating togroup.""" |
| 244 | (_, foldtype, lower, _) = fields |
| 245 | if foldtype not in ("C", "S"): |
| 246 | return |
| 247 | lower = _UInt(lower) |
| 248 | togroup.setdefault(lower, [lower]).extend(codes) |
| 249 | |
| 250 | ReadUnicodeTable(unicode_dir+"/CaseFolding.txt", 4, DoLine) |
| 251 | |
| 252 | groups = list(togroup.values()) |
| 253 | for g in groups: |
| 254 | g.sort() |
| 255 | groups.sort() |
| 256 | return togroup, groups |
| 257 | |
| 258 | |
| 259 | def Scripts(unicode_dir=_UNICODE_DIR): |
nothing calls this directly
no test coverage detected