Encode bytes, so that it gives a C string literal.
(value)
| 87 | |
| 88 | |
| 89 | def 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 | |
| 108 | def decodeCStringToPython(value): |
no test coverage detected
searching dependent graphs…