I want to use cython to wrap a C library. One function in the library is like
int hid_get_manufacturer_string(hid_device *device, wchar_t *string, size_t maxlen);
There are two questions:
What can I do with the
wchar_t
in cython;How to convert the string pointer in my .pyx file.
Declare wchar_t:
Or import from libc module:
A function to convert wchar_t to python string by using WideCharToMultiByte (see CefStringToPyString):
Since Python 3.2 you can do this with the use of PyUnicode_FromWideChar(wcharstr, -1), see the comment by compostus.