Boost logo

Boost Users :

From: Tan, Tom (Shanghai) (TTan_at_[hidden])
Date: 2008-06-18 23:29:18


>I have searched a lot in every place what is the best way to convert a
>string to a wstring (and may be vice versa). But til now I don`t got
any
>results. Can anyone give me an hint what is the best way to do that
>(also good performance?)? maybe there is something available to do
that?
>may be also with some examples.

Use member function assign().
Ex.

// wstring ->string
wstring ws(L"this is a wstring");
string s;
s.assign(ws.begin(), ws.end());// now s = "this is a wstring";

// wstring ->string
string s("this is a wstring");
wstring ws;
ws.assign(s.begin(), s.end());// now ws = L"this is a wstring";


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net