Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to convert between CString and wchar_t * (unicode) ?

1,069 views
Skip to first unread message

Joakim Andersson

unread,
May 31, 2000, 3:00:00 AM5/31/00
to
How I convert a CString to a wchar_t -field and the other way?
Example please!

/Joakim Andersson
Sweden

George Huber

unread,
May 31, 2000, 3:00:00 AM5/31/00
to
Hi,

Not suree of what you want to do, but I would try the following:

CString csMsg("This is a test");
WCHAR* wcString;

wcString = new WCHAR[csMsg.GetLength()];
MultiByteToWideChar(CP_ACP, 0, csMsg.GetBuffer(0), -1, wcString,
csMsg.GetLength());

// at this point wcString should contain the contents of "This is a test" in
unicode format.

To convert the other way use the WideCharToMultiByte function.

George

Joakim Andersson <joakim.a...@wirelesscar.com> wrote in message
news:e1KdUpty$GA....@cppssbbsa02.microsoft.com...

0 new messages