Hi all, this is my code. Please take look. Here, I am passing a static wchar array to a python function and python treats it as str object. Can you explain why and how to prevent this ?
from ctypes.wintypes import INT, WCHAR
import ctypes as ct
class FOO(ct.Structure):
_fields_ = [
('x', INT),
('y', INT),
('arr', WCHAR * 32)
]
def fillBuffer(buffer, txt):
print(type(buffer))
foo = FOO()
fillBuffer(foo.arr, "Apple")
# It prints <class 'str'>
A str is just the type that Python maps "c_wchar"s too. It can only be assumed they really are static wchar arrays, in the C code being interfaced with.
That’s the interesting part. I tried with USHORT and it treated the parameter as a str. I don’t know how to handle this. Let me explain why I am doing this. I have a GUI lib with win api functions. Last day, I tried to improve the performance of font related functions, and I found that I can speed up things by using the lfFaceName member of LOGFONTW structure. It is a static array which can hold 32 characters. So I am trying to pass the array pointer to MultiByteToWideChar function.
Thank you for the reply. I am sorry, I didn’t give the full code. But this is what I want to do.
I tried to improve the performance of font related functions in gui lib, and I found that I can speed up things by using the lfFaceName member of LOGFONTW structure. It is a static array which can hold 32 characters. So I am trying to pass the array pointer to MultiByteToWideChar function.