Boost logo

Boost Users :

Subject: [Boost-users] How to convert wide character strings to multi-byte strings ?
From: Timothy Madden (terminatorul_at_[hidden])
Date: 2010-02-02 14:02:10


Hello

What is the right way to convert from wide character strings to
multi-byte strings ? In boost or in C++ if any ?

For narrow to wide conversion I can do

wostringstream streamMsg;

streamMsg << "Narrow string";

wstring wstrMessage = streamMsg.str();

But I think that too is not a good way as it might not take the current
locale / code page /encoding /whatever into account, but just widen the
char (as a number) to an wchar_t.

So what is the right way ?
How do I write a codecvt facet for the default locale if I need one ?

Thank you,
Timothy Madden


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