12 #include <glibmm/convert.h> 19 setlocale(LC_ALL,
"");
24 for (
int i = 1; i < 256; ++i)
27 Glib::IConv iconv(
"UTF8",
"ISO8859-1");
29 iconv_t cd = iconv_open(
"UTF8",
"ISO8859-1");
30 if (cd == (iconv_t)-1)
38 size_t outbytes =
sizeof(buf2);
44 size_t res = iconv.iconv(&inbuf,& inbytes,& outbuf,& outbytes);
45 if (res == static_cast<size_t>(-1))
47 std::cerr <<
"iconv: " << std::strerror(errno) << std::endl;
51 std::cout <<
"res = " << res <<
"; inbytes = " << inbytes <<
"; outbytes = " << outbytes <<
'\n';
56 std::cout <<
"outbytes = " << outbytes <<
'\n';
57 for (
int i = 0; i <
sizeof(buf2) - outbytes; ++i)
59 unsigned int data = (
unsigned int)(
unsigned char)buf2[i];
60 std::cout << i <<
" : " << data;
61 if (data == 194 || data == 195)
64 std::cout <<
" " << (
unsigned int)(
unsigned char)buf2[i];
69 std::string s(buf2,
sizeof(buf2) - outbytes);
70 std::cout <<
"Output : \"" << s <<
"\"\n";
73 bool is_utf8 = g_get_charset(&charset);
74 std::cout <<
"g_get_charset() = " << charset << std::endl;
78 std::cout <<
"charset is not \"UTF-8\", fix that.\n";
83 std::cout <<
"strlen = " << str.length() <<
'\n';
85 std::cout <<
"Glib::ustring: \"" << str <<
"\"\n";
87 std::cout <<
"Printable characters:\n";
89 for (Glib::ustring::iterator iter = str.begin(); iter != str.end(); ++iter)
91 Glib::ustring::iterator::value_type c =* iter;
92 if (g_unichar_isprint(c))
95 std::cout << c <<
'\n';
100 std::cout <<
"Printable characters: \"" << output <<
"\"\n";