I don't think that Glib::convert can convert (or convert well) wstrings. My sugestion:
// #include <glib.h> std::wstring mywstr(L"any text"); gchar* pt_ustr = g_utf16_to_utf8((gunichar2*)mywstr.c_str(), -1, NULL, NULL, NULL); Glib::ustring myustr(pt_ustr); g_free(pt_ustr); References: 1- http://library.gnome.org/devel/glib/stable/glib-Unicode-Manipulation.html#g-utf16-to-utf8 2009/4/28 Milosz Derezynski <[email protected]> > It's not really about the data type used, but about the encoding of the > original string. > > For one, there is http://www.unicode.org/Public/PROGRAMS/CVTUTF/, which is > of course not part of glib, but is probably a good way to do it. > > Then, you can use > http://gtkmm.org/docs/glibmm-2.4/docs/reference/html/group__CharsetConv.html#g58f7e4556c436a96c64b186bbc8f7f4c, > for converting between UTF-16 (which is what I assume your wstrings are), > and UTF-8. > > Then finally you can place the result into a Glib::ustring. > > Hope this helps, > > M. > > On Tue, Apr 28, 2009 at 12:39 PM, 陈凯 <[email protected]> wrote: > >> Greetings, >> >> Recently I plan to port my app from Windows to linux using Gtkmm library. >> I found glib::ustring is recommended to use, but my app works with >> std::wstring. However, there seems no sign of documentations about the >> conversion from std::wstring to glib::string in the gtkmm library. I got >> stuck here. Could some one help me out of the question? Thanks in advance >> :) >> >> Regards >> >> CHEN Kai >> >> >> _______________________________________________ >> gtkmm-list mailing list >> [email protected] >> http://mail.gnome.org/mailman/listinfo/gtkmm-list >> >> > > > -- > Please note that according to the German law on data retention, > information on every electronic information exchange with me is > retained for a period of six months. > [Bitte beachten Sie, dass dem Gesetz zur Vorratsdatenspeicherung zufolge > jeder elektronische Kontakt mit mir sechs Monate lang gespeichert wird.] > > _______________________________________________ > gtkmm-list mailing list > [email protected] > http://mail.gnome.org/mailman/listinfo/gtkmm-list > >
_______________________________________________ gtkmm-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtkmm-list
