Reputation: 11803
I found this topic Convert between string, u16string & u32string and the solution (which looks really great) works only using libc++ not libstdc++. Currently libc++ is not usable - it is hard to compile and dont work good on Windows.
Is there any method to convert between these representations using C++11 and libstdc++, which works on all platforms?
I'm especially interested in converting u32_string to string (utf8) and vice versa.
Upvotes: 5
Views: 2298
Reputation: 356
There is a way portable way in C++11 to do this through the wstring_convert class.
However, it seems that it is not yet implemented libstdc++ (as of gcc 4.8)
The same applies to:
codecvt<char16_t, char, mbstate_t>.
codecvt<char32_t, char, mbstate_t>.
codecvt_utf8.
codecvt_utf16.
codecvt_utf8_utf16.
In fact the header <codecvt>
is still not present in the gcc distribution.
Upvotes: 2
Reputation: 7247
You could use utf8cpp (http://utfcpp.sourceforge.net/) it provides those converters as easily useable C++.
Upvotes: 0