尝试使用Glibmm-2.4输出中文返回“转换输入中的无效字节序列”。
#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;
}
你知道我在这里做错什么了吗?使用Ubuntu14.04.2 i386 LTS,g++,glibmm-2.4
发布于 2015-03-10 08:29:17
为了使用ustring并让它正确地执行流运算符的隐式转换,需要对区域设置进行初始化,例如std::locale::global(std::locale(""));,否则ASCII之外的字符不能正确转换。
这是记录在案的这里
https://stackoverflow.com/questions/28953866
复制相似问题