MCPcopy
hub / github.com/Nuitka/Nuitka / encodePythonStringToC

Function encodePythonStringToC

nuitka/utils/CStrings.py:89–105  ·  view source on GitHub ↗

Encode bytes, so that it gives a C string literal.

(value)

Source from the content-addressed store, hash-verified

87
88
89def encodePythonStringToC(value):
90 """Encode bytes, so that it gives a C string literal."""
91
92 # Not all compilers allow arbitrary large C strings, therefore split it up
93 # into chunks. That changes nothing to the meanings, but is easier on the
94 # parser. Currently only MSVC is known to have this issue, but the
95 # workaround can be used universally.
96
97 result = _encodePythonStringToC(value[:16000])
98 value = value[16000:]
99
100 while value:
101 result += " "
102 result += _encodePythonStringToC(value[:16000])
103 value = value[16000:]
104
105 return result
106
107
108def decodeCStringToPython(value):

Callers 7

getModuleCodeFunction · 0.90
_generateModuleCodeFunction · 0.90
getStatementTraceFunction · 0.90

Calls 1

_encodePythonStringToCFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…