Trying to use Glibmm-2.4 to output Chinese returns "Invalid byte sequence in conversion input".
#include <iostream>
#include <glibmm/ustring.h>
#include <glibmm/convert.h>
int main()
{
Glib::ustring myUstring = "中";
try
{
std::cout << myUstring;
}
catch(Glib::ConvertError e)
{
std::cout << e.what();
}
return 0;
}
Any idea what I am doing wrong here? Using Ubuntu 14.04.2 i386 LTS, g++, glibmm-2.4
An initialization of the locale is needed E.g. std::locale::global(std::locale(""));
in order to use ustring and have it do the stream operator's implicit conversion correctly, otherwise characters outside of ASCII aren't converted correctly.
This is documented here