Re: UTF-16 in gtkmm?



Am Sat, 17 May 2008 12:40:30 +0100 schrieb Chris Vine:

> On Sat, 2008-05-17 at 11:43 +0200, Andreas Volz wrote:
> > Hello,
> > 
> > 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"[1], 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 object.
> 
> 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.

Thanks, I'll try it. Any ideas why there's no glibmm wrapper for that?

regards
Andreas


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]