Convert python string into bytes compatible with char* C string
(string)
| 176 | |
| 177 | |
| 178 | def string2utf8(string): |
| 179 | """Convert python string into bytes compatible with char* C string""" |
| 180 | if string is None: |
| 181 | return ffi.NULL |
| 182 | elif isinstance(string, str): |
| 183 | return string.encode('utf8') |
| 184 | # Anything else illegal - specifically python3 bytes |
| 185 | raise TypeError("Unrecognized string type: %r (%s)" % (string, type(string))) |
| 186 | |
| 187 | |
| 188 | def utf82string(string): |
no test coverage detected