Hi,
I'm writing my strings hardcoded into the program, so I want to make
use of string literals in C++.
When I use gtkmm with vc++ 2005, sizeof(wchar_t) is 2.
So I assumed utf-16 encoding and wrote:
Glib::ustring w2ustring(std::wstring const &w)
{
gunichar2 const* utf16= reinterpret_cast<gunichar2 const*>(w.c_str());
gchar* utf8= g_utf16_to_utf8(utf16, -1, 0, 0, 0);
Glib::ustring u(utf8); g_free(utf8);
return u;
}
Which seems to work great like
Glib::ustring u(w2ustring(L"üö"));
But on linux with a unicode terminal,
I can just set
std::locale::global(std::locale("en_US.UTF-8"));
Glib::ustring u(Glib::locale_to_utf8("üö"));
And the code up there doesn't work (wchar_t is actually 4 bytes)
And even the ucs4 output warnings and the resulting ustring is garbage
or I get a segfault.
So no utf16 to utf8 or ucs4 to utf8 conversions.
Shall I use two separate codes for these platforms?
Is there a unified solution?
_______________________________________________
gtkmm-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtkmm-list