First, don't use TCHAR's/TEXT() - just enabled Unicode in your project settings and use L"" string literals and wchar_t as your wide char type.
I'm also not a big fan of MS typedef's - I prefer "wchar_t*" instead of LPWSTR.
Next you should understand the pitfalls that can bite you when using extended character literals in your source code ("öüç"). In short, you'll need to use a wide string literal and save your source file as UTF8-with-BOM. In long, Non-English characters with cout
Here are some conversion utils you can use:
Code:
#include <windows.h>
#include <string>
#include <sstream>
#include <vector>
std::wstring str_to_wstr(const std::string &str, UINT cp = CP_ACP)
{
int len = MultiByteToWideChar(cp, 0, str.c_str(), str.length(), 0, 0);
if (!len)
return L"ErrorA2W";
std::vector<wchar_t> wbuff(len + 1);
// NOTE: this does not NULL terminate the string in wbuff, but this is ok
// since it was zero-initialized in the vector constructor
if (!MultiByteToWideChar(cp, 0, str.c_str(), str.length(), &wbuff[0], len))
return L"ErrorA2W";
return &wbuff[0];
}//str_to_wstr
std::string wstr_to_str(const std::wstring &wstr, UINT cp = CP_ACP)
{
int len = WideCharToMultiByte(cp, 0, wstr.c_str(), wstr.length(),
0, 0, 0, 0);
if (!len)
return "ErrorW2A";
std::vector<char> abuff(len + 1);
// NOTE: this does not NULL terminate the string in abuff, but this is ok
// since it was zero-initialized in the vector constructor
if (!WideCharToMultiByte(cp, 0, wstr.c_str(), wstr.length(),
&abuff[0], len, 0, 0))
{
return "ErrorW2A";
}//if
return &abuff[0];
}//wstr_to_str
But if you just save your source files as UTF8 and use the follow, it should work:
Code:
MessageBox(0, L"öüç", L"Title", MB_OK);
gg