在 mbstowcs_s 函数 SizeInWords 参数的上下文中,Word 的大小是多少?

What is the size of a Word in the context of the mbstowcs_s function SizeInWords parameter?

我很难确定在 Windows API 函数 mbstowcs_s 的上下文中单词的确切大小。这里是MSDN的相关信息以及link.

mbstowcs_s, _mbstowcs_s_l

Converts a sequence of multibyte characters to a corresponding sequence of wide characters. Versions of mbstowcs, _mbstowcs_l with security enhancements as described in Security Features in the CRT.

Parameters

[out] pReturnValue - The number of characters converted.

[out] wcstr - Address of buffer for the resulting converted wide character string.

[in] sizeInWords - The size of the wcstr buffer in words.

[in] mbstr - The address of a sequence of null terminated multibyte characters.

[in] count - The maximum number of wide characters to store in the wcstr buffer, not including the terminating null, or _TRUNCATE.

这是 MSDN 页面的 link:https://msdn.microsoft.com/en-us/library/eyktyxsx.aspx

有什么想法吗?

一般一个字就是16位。

为了确保,分配一个比方说 100 字节的缓冲区,并用 0xff 填充它们。然后为 sizeInWords 传递 16 和至少 16 个字符的 mbstr。调用完成后,在调试器中检查 wcstr。如果我是对的,缓冲区的前 32 个字节将具有字符值,其余部分仍为 0xff。 (当然这忽略了wcstr的某些值可能是0xff的事实)