For last two days I've been trying to convert utf-8
string to cp437
string and I've already tried this answer.
Example situation would be converting char *utf8="\xC2\xBB"
to char *cp437="\xAF"
(or 175 decimal if you will).
I came up with many variations of this:
struct ConsoleOutputWrapper {
boost::locale::generator generator;
std::string c_output; // Charset name
std::locale l_output; // Locale
ConsoleOutputWrapper() :
generator(),
c_output("CP437")
{
generator.locale_cache_enabled(true);
l_output = generator(c_output);
}
void operator<<(const char* str)
{
std::cout << boost::locale::conv::from_utf<char>(str, l_output);
}
};
// Test
ConsoleOutputWrapper k;
k << "\xc2\xbb";
But the best conversion I've got to was >
instead of ยป
.
Any ideas how to convert special characters like these using boost?