Original Post
Is it possible to optimize the following piece of code? There are many unnecessary string copies...
std::wstring ascii_cast(const char *Ascii)
{
// Get number of char's in the string
size_t Length = std::strlen(Ascii);
// Create an temporarily buffer
std::vector<wchar_t> Wide(Length + 1);
// Convert 'Ascii' to Unicode
MultiByteToWideChar(CP_ACP, 0, Ascii, -1, &Wide[0], (int)Length + 1);
// Create an temporarily wstring
std::wstring WideStr(&Wide[0]);
// Return the Unicode string
return WideStr;
}