MCPcopy Index your code
hub / github.com/ScrapeGraphAI/toonify / escape_string

Function escape_string

toon/utils.py:55–75  ·  view source on GitHub ↗

Escape special characters in a string for TOON encoding. Args: value: String to escape Returns: Escaped string

(value: str)

Source from the content-addressed store, hash-verified

53
54
55def escape_string(value: str) -> str:
56 """
57 Escape special characters in a string for TOON encoding.
58
59 Args:
60 value: String to escape
61
62 Returns:
63 Escaped string
64 """
65 # Escape backslashes first
66 value = value.replace(BACKSLASH, BACKSLASH + BACKSLASH)
67 # Escape quotes
68 value = value.replace(QUOTE, BACKSLASH + QUOTE)
69 # Escape newlines
70 value = value.replace(NEWLINE, BACKSLASH + 'n')
71 # Escape tabs
72 value = value.replace('\t', BACKSLASH + 't')
73 # Escape carriage returns
74 value = value.replace('\r', BACKSLASH + 'r')
75 return value
76
77
78def unescape_string(value: str) -> str:

Callers 1

quote_stringFunction · 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…