MCPcopy Index your code
hub / github.com/rspeer/python-ftfy / _build_width_map

Function _build_width_map

ftfy/chardata.py:233–247  ·  view source on GitHub ↗

Build a translate mapping that replaces halfwidth and fullwidth forms with their standard-width forms.

()

Source from the content-addressed store, hash-verified

231
232
233def _build_width_map() -> dict[int, str]:
234 """
235 Build a translate mapping that replaces halfwidth and fullwidth forms
236 with their standard-width forms.
237 """
238 # Though it's not listed as a fullwidth character, we'll want to convert
239 # U+3000 IDEOGRAPHIC SPACE to U+20 SPACE on the same principle, so start
240 # with that in the dictionary.
241 width_map = {0x3000: " "}
242 for i in range(0xFF01, 0xFFF0):
243 char = chr(i)
244 alternate = unicodedata.normalize("NFKC", char)
245 if alternate != char:
246 width_map[i] = alternate
247 return width_map
248
249
250WIDTH_MAP = _build_width_map()

Callers 1

chardata.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected