Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2002-11-30 08:22:03


Speaking of different character types, perhaps there could also be interest
for converting between strings of different character types, as well? For
example:

std::string str=lexical_cast<std::string>(L"A wide character string");
std::wstring wstr=lexical_cast<std::wstring>("A character string");

and the same for char->wchar_t and wchar_t->char.

This currently gives bad_lexical_cast.

Perhaps this is possible to do already, using some other library facility?

This could be done, using conversions taking into account the currently set
locale. char->wchar_t should always succeed, but not necessarily the other
way, so I guess it should then throw bad_lexical_cast if it's not possible.

Regards,

Terje


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk