Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
嗨,如何将 BYTE* 转换为 wstring?
我用谷歌搜索了它,但我找不到它。
BYTE* value = new BYTE[size]; wstring wstr;
我想为 wstr 赋值。怎么做 ?
假设您的字节数组是 UTF-16 编码的,您可以简单地将缓冲区转换为wchar_t*并将其传递给字符串的构造函数:
wchar_t*
wstring wstr(reinterpret_cast<wchar_t*>(value), size/sizeof(wchar_t));
如果缓冲区包含一个空终止符,您需要从传递给构造函数的长度中减去它。