Boost logo

Boost Users :

From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2007-01-22 17:49:29


On 1/22/07, Tobias Schwinger <tschwinger_at_[hidden]> 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



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