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

Function load_big5_map

Tools/unicode/genmap_tchinese.py:103–134  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

101
102
103def load_big5_map():
104 mapfile = open_mapping_file('python-mappings/BIG5.txt', MAPPINGS_BIG5)
105 with mapfile:
106 big5decmap = loadmap(mapfile)
107 # big5 mapping fix: use the cp950 mapping for these characters as the file
108 # provided by unicode.org doesn't define a mapping. See notes in BIG5.txt.
109 # Since U+5341, U+5345, U+FF0F, U+FF3C already have a big5 mapping, no
110 # roundtrip compatibility is guaranteed for those.
111 for m in """\
112 0xA15A 0x2574
113 0xA1C3 0xFFE3
114 0xA1C5 0x02CD
115 0xA1FE 0xFF0F
116 0xA240 0xFF3C
117 0xA2CC 0x5341
118 0xA2CE 0x5345""".splitlines():
119 bcode, ucode = list(map(eval, m.split()))
120 big5decmap[bcode >> 8][bcode & 0xff] = ucode
121 # encoding map
122 big5encmap = {}
123 for c1, m in list(big5decmap.items()):
124 for c2, code in list(m.items()):
125 big5encmap.setdefault(code >> 8, {})
126 if code & 0xff not in big5encmap[code >> 8]:
127 big5encmap[code >> 8][code & 0xff] = c1 << 8 | c2
128 # fix unicode->big5 priority for the above-mentioned duplicate characters
129 big5encmap[0xFF][0x0F] = 0xA241
130 big5encmap[0xFF][0x3C] = 0xA242
131 big5encmap[0x53][0x41] = 0xA451
132 big5encmap[0x53][0x45] = 0xA4CA
133
134 return big5decmap, big5encmap
135
136
137def load_cp950_map():

Callers 1

main_twFunction · 0.85

Calls 7

open_mapping_fileFunction · 0.85
loadmapFunction · 0.85
listClass · 0.85
splitlinesMethod · 0.45
splitMethod · 0.45
itemsMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…