MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / escape_control_characters

Function escape_control_characters

mitmproxy/utils/strutils.py:69–80  ·  view source on GitHub ↗

Replace all unicode C1 control characters from the given text with a single "." Args: keep_spacing: If True, tabs and newlines will not be replaced.

(text: str, keep_spacing=True)

Source from the content-addressed store, hash-verified

67
68
69def escape_control_characters(text: str, keep_spacing=True) -> str:
70 """
71 Replace all unicode C1 control characters from the given text with a single "."
72
73 Args:
74 keep_spacing: If True, tabs and newlines will not be replaced.
75 """
76 if not isinstance(text, str):
77 raise ValueError(f"text type must be unicode but is {type(text).__name__}")
78
79 trans = _control_char_trans_newline if keep_spacing else _control_char_trans
80 return text.translate(trans)
81
82
83def bytes_to_escaped_str(

Callers 1

hexdumpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…