This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: UTF-8 support - char or wchar_t?


Ole Laursen wrote:

Martin Sebor <sebor@roguewave.com> writes:

[...]


The most portable way to do this, though, is to forget about codecvt
and use iconv directly.


Thanks! What you are suggesting is to use a std::wostringstream,
extract a std::wstring with str(), put the data inside a std::string
and use an iconv wrapper to convert from the wchar_t encoding to
UTF-8, right?

I don't think I suggested that. With iconv, unless you actually want wchar_t, you can just convert ordinary multibyte characters (say a char* encoded in ISO-8859-15 to a char* encoded in UTF-8 or vice versa). You don't need to involve wchar_t as an intermediate representation as you might with codecvt (e.g., a char* in 8859 to UCS-4 encoded wchar_t*, and then the same wchar_t* to UTF-8 with another codecvt). I hope I didn't just confuse things for you :)

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]