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)
| 67 | |
| 68 | |
| 69 | def 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 | |
| 83 | def bytes_to_escaped_str( |
no outgoing calls
no test coverage detected
searching dependent graphs…