Hi all,
I see that ctypes docs says c_wchar_p is equal to string in python. I know that python strings are utf-8 by default. And wchar is utf-16. Does ctypes uses MultiByteToWideChar to convert Python strings to wchar ?
NOTE: MultiByteToWideChar is a windows api function. Question is asked under windows os context.
Python strings aren’t UTF-8. Depending on the contents they can be ASCII, UTF-16 or UTF-32. That’s more of an implementation detail and could change, externally they’re just abstractly Unicode. Ctypes doesn’t call Windows APIs to do the wchar_t, instead it uses PyUnicode_AsWideCharString() → unicode_copy_as_widechar() which directly does the conversion.