I\'m trying to convert a UTF-8 string
to a ISO-8859-1 char*
for use in legacy code. The only way I\'m seeing to do this is with iconv.
I w
Alfs suggestion implemented in C++11
#include
#include
#include
#include
auto i = u8"H€llo Wørld";
std::wstring_convert> utf8;
auto wide = utf8.from_bytes(i);
std::string out;
out.reserve(wide.length());
std::transform(wide.cbegin(), wide.cend(), std::back_inserter(out),
[](const wchar_t c) { return (c <= 255) ? c : '?'; });
// out now contains "H?llo W\xf8rld"