I need to construct a multi-string (REG_MULTI_SZ
) in C++ from a list of values represented in a std::vector<std::wstring>
.
This is what first came to mind but was of course incorrect:
std::wstring GetMultiString(std::vector<std::wstring> Values)
{
std::wstringstream ss;
for (const std::wstring& Value : Values) {
ss << Value;
ss << L"\0";
}
ss << L"\0";
return ss.str();
}
Upon inspection, the returned string didn't have any embedded NULL characters.
ss << L"\0";
is same asss << L"";
and does nothing. The both point to null-terminated char literals, how much nulls are there after the first one, doesn't matter – PeerL"\0"s
) would behave differently? – BoyhoodL"\0"s
is a string containing the zero char. – Peer