-
Unicode and MBCS (multi-byte charset) should not be interchanged, if possible. Either you use unicode in your app or MCBS.
It's quite possible the √ exists in MBCS too.
For Windows programming, I suggest the use of Unicode.
There are functions that can convert to and from Unicode, but unless you really need them, it's not really recommended.
-
You can convert to and from, wide and narrow strings using mbstowcs() and wcstombs(). Here's one way to append an narrow string to a wide string:
Code:
void AppendAtoW(std::wstring &wstr, const char *astr)
{
const size_t buff_len = 128;
wchar_t buff[buff_len];
mbstowcs(buff, astr, buff_len);
buff[buff_len - 1] = 0; // in case astr is longer than buff_len
wstr += buff;
}//AppendAtoW
>> my_str = L"√";
This seems dangerous to me - because of two assumptions: 1) that your code editor saves your source code the "right" way; 2) that your compiler interprets the string literal as you expect. For (2), I'm not real familiar with what the standard has to say about this - but I'll start reading.
However, it sure is nice to see the same glyph in your source code that you intend to show in the control :) And it seems that mikeman118's editor and compiler are doing the "right" thing - based on the output: "√琠獥t쳌쳌쳌쳌".
gg
-
Are you doing pure Win32 programming for Windows? It looks that way to me.
I'd rather recommend you get a framework like MFC.
-
Thank you everyone, everything works now!
BTW Codeplug I'm using Visual C++ 2008 Express Edition, in case you were wondering.