MCPcopy Create free account
hub / github.com/agent0ai/agent-zero / sanitize_string

Function sanitize_string

helpers/strings.py:6–10  ·  view source on GitHub ↗
(s: str, encoding: str = "utf-8")

Source from the content-addressed store, hash-verified

4from helpers import files
5
6def sanitize_string(s: str, encoding: str = "utf-8") -> str:
7 # Replace surrogates and invalid unicode with replacement character
8 if not isinstance(s, str):
9 s = str(s)
10 return s.encode(encoding, 'replace').decode(encoding, 'replace')
11
12def calculate_valid_match_lengths(first: bytes | str, second: bytes | str,
13 deviation_threshold: int = 5,

Callers 6

after_executionMethod · 0.90
write_fileFunction · 0.90
after_executionMethod · 0.90
_sanitize_tool_textFunction · 0.90
_log_htmlMethod · 0.85
getMethod · 0.85

Calls 2

decodeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected