MCPcopy
hub / github.com/rspeer/python-ftfy / _build_control_char_mapping

Function _build_control_char_mapping

ftfy/chardata.py:97–116  ·  view source on GitHub ↗

Build a translate mapping that strips likely-unintended control characters. See :func:`ftfy.fixes.remove_control_chars` for a description of these codepoint ranges and why they should be removed.

()

Source from the content-addressed store, hash-verified

95
96
97def _build_control_char_mapping() -> dict[int, None]:
98 """
99 Build a translate mapping that strips likely-unintended control characters.
100 See :func:`ftfy.fixes.remove_control_chars` for a description of these
101 codepoint ranges and why they should be removed.
102 """
103 control_chars: dict[int, None] = {}
104
105 for i in itertools.chain(
106 range(0x00, 0x09),
107 [0x0B],
108 range(0x0E, 0x20),
109 [0x7F],
110 range(0x206A, 0x2070),
111 [0xFEFF],
112 range(0xFFF9, 0xFFFD),
113 ):
114 control_chars[i] = None
115
116 return control_chars
117
118
119CONTROL_CHARS = _build_control_char_mapping()

Callers 1

chardata.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected