MCPcopy Index your code
hub / github.com/python/cpython / parse_gb18030map

Function parse_gb18030map

Tools/unicode/genmap_schinese.py:37–52  ·  view source on GitHub ↗
(fo)

Source from the content-addressed store, hash-verified

35
36
37def parse_gb18030map(fo):
38 m, gbuni = {}, {}
39 for i in range(65536):
40 if i < 0xd800 or i > 0xdfff: # exclude unicode surrogate area
41 gbuni[i] = None
42 for uni, native in re_gb18030ass.findall(fo.read()):
43 uni = eval('0x'+uni)
44 native = [eval('0x'+u) for u in native.split()]
45 if len(native) <= 2:
46 del gbuni[uni]
47 if len(native) == 2: # we can decode algorithmically for 1 or 4 bytes
48 m.setdefault(native[0], {})
49 m[native[0]][native[1]] = uni
50 gbuni = [k for k in gbuni.keys()]
51 gbuni.sort()
52 return m, gbuni
53
54def main():
55 print("Loading Mapping File...")

Callers 1

mainFunction · 0.85

Calls 6

findallMethod · 0.45
readMethod · 0.45
splitMethod · 0.45
setdefaultMethod · 0.45
keysMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…