Re: backwards compatible .desktop files



Darin Adler <darin bentspoon com> writes:

> On 1/18/02 3:32 PM, "Owen Taylor" <otaylor redhat com> wrote:
> 
> > Darin Adler <darin bentspoon com> writes:
> > 
> >> On 1/18/02 3:02 PM, "Owen Taylor" <otaylor redhat com> wrote:
> >> 
> >>> But since the KDE desktop files and old GNOME desktop files don't have
> >>> it, the approach to "is UTF8" is simple. If the entire file is valid
> >>> UTF-8, then the desktop file is in UTF-8. This turns out to be a very
> >>> accurate.
> >> 
> >> Is there a good reason not to do this heuristic in g_filename_to_utf8 when
> >> G_BROKEN_FILENAMES is not set?
> > 
> > An accurate heuristic is impossible, plus, more importantly, heuristics
> > don't work round-trip.
> 
> Conversion of an arbitrary filename to valid UTF-8 also doesn't work
> round-trip, so this doesn't matter for Nautilus -- I can see how it might
> matter for other g_filename_to_utf8 users.
> 
> Does g_filename_to_utf8 maybe have to validate the string it dups in the
> case where it just does a g_strdup? I'm a little concerned that we don't
> have examples of using this in real programs and are missing these
> subtleties because of that.

I think you are being confused by the name strdup_len() ... it
does validate.
 
> You first said that "this turns out to be a very accurate" about the
> heuristic, then you said "an accurate heuristic is impossible".

The more text, the more accurate; at the level of an entire desktop
file, "if it's valid UTF-8 , it _is_ UTF-8", it's very accurate, but
we used to do it the individual key level, and there were one or two
misses in the set of desktop files Red Hat shipped with things that
appeared to be UTF-8 but weren't.

(They tend to occur more for things like Chinese, than for
European languages.)

But more importantly, I can do heuristics for g_filename_to_utf8(),
but not the other way around. And I'd like the filename => utf8 =>
filename rountrip conversion to be reliable.

You might want want to add a request for a
"g_filename_to_display_utf8()" to bugzilla; I think for now, you
should probably call g_filename_to_utf8() and then if that fails, try
g_locale_to_utf8().

Regards,
                                        Owen


 



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