Re: UTF-16 in gtkmm?
- From: Chris Vine <chris cvine freeserve co uk>
- To: Andreas Volz <lists brachttal net>
- Cc: gtkmm-list gnome org
- Subject: Re: UTF-16 in gtkmm?
- Date: Sat, 17 May 2008 12:40:30 +0100
On Sat, 2008-05-17 at 11:43 +0200, Andreas Volz wrote:
> I like to read Unicode strings into my gtkmm application that are
> written in UTF-16. There's only the glib::ustring class to handle
> UTF-8. Is there a UTF-16 string class or a way to convert the UTF-16
> string to UTF-8?
> Then I need to write back my Unicode strings in UTF-16. I found the
> docs about "Character Set Conversion", but I don't see how they'll
> help me.
You can convert from UTF-16 to UTF-8 using g_utf16_to_utf8() (for which
purpose you will need to include glib/gunicode.h). You will need to
call g_free() on the return value after putting it in a Glib::ustring
You can go the other way with g_utf8_to_utf16(). It returns an array of
type gunichar2, which is typedef'ed to guint16, also requiring to be
g_free'd when you have finished with it.
] [Thread Prev