How to work with UTF-16 in python ctypes?
问题 I have a foreign C library which uses utf-16 in API: as function arguments, return values and structure members. On Windows its OK with ctypes.c_wchar_p, but under OSX ctypes uses UCS-32 in c_wchar and I could not find the way to support utf-16. Here is my research: Use _SimpleCData subclassing to redefine _check_retval_. it allows a transparent conversion of utf-16 to Python string. can be placed as C structure member But it doesn't allow to handle strings as arguments, its from_param()