我知道C中的代码是这样的:
WCHAR string[] = L"string\0";
所以我尝试(在Python中):
string = ctypes.create_unicode_buffer("String\0")
但这会去掉的空字符。
如果我使用create_string_buffer
它确实有效。
string = ctypes.create_string_buffer("String\0")
现在字符串的末尾有两个空字符:
>>> string.raw
'String\x00\x00'
为什么这对unicode不起作用?
编辑:
这是可行的(来源:Python Ctypes Null Terminated String Block):
string = ctypes.wstring_at(ctypes.create_unicode_buffer(u'string\0'), 7)
目前没有回答
相关问题 更多 >
编程相关推荐