size_t StrToWstr(wstring& aDst, const string& aSrc)
{
size_t length;
length = mbstowcs(NULL, aSrc.c_str(), 0);
if (length != static_cast<size_t>(-1)) {
wchar_t *buffer = new wchar_t[length + 1];
length = mbstowcs(buffer, aSrc.c_str(), length);
buffer[length] = L'\0';
aDst.assign(buffer);
delete[] buffer;
}
return length;
}
void settext(std::string params) {
std::locale::global(std::locale("Russian"));
wstring ws;
StrToWstr(ws, params); // ws contain correct word "Да"
char Buff[512];
sprintf(Buff, "%ws", ws.c_str()); // Buff is contain weird characters
}
int main()
{
settext("Да");
return 0;
}