On 1/22/07, Tobias Schwinger <tschwinger@isonews2.com> wrote:
John Christopher wrote:
> Hello,
> Does Boost contain facilities to convert std::string into std::wstring and
> the other way around?
Should there?
std::string a;
std::wstring b(
a.begin(),a.end());
std::string c(b.begin(),b.end());
All string algorithms in Boost are templates so they should work fine
with both std::string and std::wstring.
http://www.boost.org/doc/html/string_algo.html
Regards,
Tobias
I think the real question is whether the OP was hoping for Unicode conversions of some kind in the process. ie what 'type' (sematically) are the wchar_t's and char's? UTF16? UTF32? (what size is the wchar_t?) etc.
Also, does the last line:
std::string c(b.begin(), b.end())
give at least a compiler warning about downconverting from wchar_t to char, and thus losing bits? (Which would be a hint that maybe you need some Unicode conversion or something else.)
Tony