xlog-discussion
[Top][All Lists]
Advanced

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

Re: [Xlog-discussion] UTF8 support in 0.9cvs, and other wishes


From: Tomi Manninen
Subject: Re: [Xlog-discussion] UTF8 support in 0.9cvs, and other wishes
Date: 11 Aug 2003 21:37:58 +0300

On Mon, 2003-08-11 at 20:59, Joop Stakenborg wrote:

> >         gchar *tmp;
> >         ...
> >         tmp = g_strdup (g_locale_to_utf8("hello world", -1, 
> >                 NULL, NULL, NULL));
> >         g_object_set (G_OBJECT(window), "title", tmp, NULL);
> >         g_free (tmp);

> Okay, fixed in CVS, please check-out a new log.c and load a log with 
> french characters. I am only testing date, name, qth, freefield1, 
> freefield2 and remarks fields for foreign characters and convert them to 
> UTF-8. I guess the other fields should be safe. When you save the log, 
> these fields are converted back again to your locale, so you can keep on 
> using your favourite text editor.

As I have been playing with this in gmfsk, I'll jump in with a small
warning. The g_locale_to_utf8() call may be a bit dangerous in some 
situations as the users locale might also be (mis)configured so that
the charset used in the configuration does not accept 8 bit characters
at all. The call then fails if it encounters any 8 bit chars and
returns NULL. This might not be an issue in xlog but it's worth to have 
good error checking and handling when using it (or use g_convert() with
explicit charsets). I learned this the hard way when Carl ported gmfsk 
to BSD.. :)

And btw g_locale_to_utf8() allocates the returned string so the
strdup above is not needed.

Oh, and another potential source of problems is filenames. If you have
configurable filenames you need to convert them with 
g_filename_from_utf8() before using...

-- 
Tomi Manninen           Internet:  address@hidden
OH2BNS                  AX.25:     address@hidden
KP20ME04                Amprnet:   address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]