MCPcopy Create free account
hub / github.com/ScrapeGraphAI/toonify / unescape_string

Function unescape_string

toon/utils.py:78–114  ·  view source on GitHub ↗

Unescape special characters in a TOON string. Args: value: Escaped string Returns: Unescaped string

(value: str)

Source from the content-addressed store, hash-verified

76
77
78def unescape_string(value: str) -> str:
79 """
80 Unescape special characters in a TOON string.
81
82 Args:
83 value: Escaped string
84
85 Returns:
86 Unescaped string
87 """
88 result = []
89 i = 0
90 while i < len(value):
91 if value[i] == BACKSLASH and i + 1 < len(value):
92 next_char = value[i + 1]
93 if next_char == 'n':
94 result.append(NEWLINE)
95 i += 2
96 elif next_char == 't':
97 result.append('\t')
98 i += 2
99 elif next_char == 'r':
100 result.append('\r')
101 i += 2
102 elif next_char == QUOTE:
103 result.append(QUOTE)
104 i += 2
105 elif next_char == BACKSLASH:
106 result.append(BACKSLASH)
107 i += 2
108 else:
109 result.append(value[i])
110 i += 1
111 else:
112 result.append(value[i])
113 i += 1
114 return ''.join(result)
115
116
117def quote_string(value: str) -> str:

Callers 1

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