我需要處理低級別存儲在寬字符串中的數據。我能轉換成的Bytes
一個vector
以下方法:C++在Byte向量和wstring之間進行轉換
typedef unsigned char Byte;
wstring mystring = L"my wide string";
Byte const *pointer = reinterpret_cast<Byte const*>(&mystring[0]);
size_t size = mystring.size() * sizeof(mystring.front());
vector<Byte> byteVector(pointer, pointer + size);
不過,我有麻煩走另一條路;我對鑄造不是很熟悉。如何將vector
的Bytes
轉換爲wstring
?