Passing utf-16 string to a Windows function
问题 I have a Windows dll called some.dll with the following function: void some_func(TCHAR* input_string) { ... } some_func expects a pointer to utf-16 encoded string. Running this python code: from ctypes import * some_string = "disco duck" param_to_some_func = c_wchar_p(some_string.encode('utf-16')) # here exception! some_dll = ctypes.WinDLL(some.dll) some_dll.some_func(param_to_some_func) fails with exception "unicode string or integer address expected instead of bytes instance " The