MCPcopy Index your code
hub / github.com/nodejs/node / EscapeForCString

Function EscapeForCString

tools/gyp/pylib/gyp/__init__.py:30–41  ·  view source on GitHub ↗
(string: bytes | str)

Source from the content-addressed store, hash-verified

28
29
30def EscapeForCString(string: bytes | str) -> str:
31 if isinstance(string, str):
32 string = string.encode(encoding="utf8")
33
34 backslash_or_double_quote = {ord("\\"), ord('"')}
35 result = ""
36 for char in string:
37 if char in backslash_or_double_quote or not 32 <= char < 127:
38 result += "\\%03o" % char
39 else:
40 result += chr(char)
41 return result
42
43
44def DebugOutput(mode, message, *args):

Callers 1

LoadFunction · 0.85

Calls 1

encodeMethod · 0.80

Tested by

no test coverage detected