MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / escape

Function escape

tools/file_packager.py:221–234  ·  view source on GitHub ↗
(c)

Source from the content-addressed store, hash-verified

219 return c >= 0x20 and c <= 0x7E
220
221 def escape(c):
222 if is_print(c):
223 return chr(c)
224 escape_chars = {
225 '\b': '\\b',
226 '\f': '\\f',
227 '\n': '\\n',
228 '\r': '\\r',
229 '\t': '\\t',
230 }
231 if c in escape_chars:
232 return escape_chars[c]
233 # Encode all other chars as three octal digits(!)
234 return '\\%s%s%s' % (oct(c >> 6), oct(c >> 3), oct(c >> 0))
235
236 return ''.join(escape(c) for c in string.encode('utf-8'))
237

Callers 2

to_asm_stringFunction · 0.70
to_c_symbolFunction · 0.70

Calls 1

is_printFunction · 0.85

Tested by

no test coverage detected