Re: [RFC] Glib::filename_(to|from)_unicode => Glib->filename_(to|from)_unicode?



On Thu, Jan 08, 2004 at 11:43:50AM +0100, Bjarne Steinsbø <bosteins broadpark no> wrote:
On the other hand, looking at the implementation, they don't seem to do 
very much (or anything at all),
   
Well, they convert filenames into the correct format expected by Glib and
Gtk2 (see below, though, for a slightly better explanation, or read the
Glib manpage, they are actually documented).

nor do they have an equivalent in glib.  

They are straight interfaces to glib functions, so I don't quite
understand this one :)

What's the point of implementing them at all?

The ability to use filenames in gtk+ (and other libs). Without them it's
rather difficult to use file requestors or load files, as functions want
paths in either local or utf-8 encoding, and these two functions are the
only means to convert between them in the same way other parts of the
libg* family does.

Anyway, I devoted a great deal of documentation on these functions in
Glib, and I would be happy if you read it and told me which points were
still unclear. Using these functions is subtle, but failure to use them
properly will result in programs only supporting ascii, which is plain
inacceptable in most parts of the world.

Shouldn't they just be dropped?

If they are dropped, how would they get replaced? Here is an example of
how it's used in one of my programs:

  new_from_file Gtk2::Gdk::Pixbuf Glib::filename_to_unicode $path;

Without the filename_to_unicode call, it's only possible to load files
with ascii characters as name (it's actually a bit more difficult than
that, but having that function works in most cases).

If you don't have it, you'd have to use the Encode module, but then the
question is what encoding you would use. Using the glib functions that are
used by gtk+ etc. themselves ensures that the results will be identical,
no matter how wrong they are, as conversion is at least consistent betwene
youer file requester, perl and pixbuf.

There are many methods in gtk+ (and other libs) that expect filenames
in native format, and perl has no knowledge about these things (perl
only differentiates between (unicode) text and (binary) data, it has no
encoding attached to strings other than that, so you can't convert to
native format automaticaly or vice versa).

Handling characters is subtly different because the models of glib and
perl differ slightly (and perl lacks a lot with respect to handling of
filenames), and using these functions consistently ensures a basic level
of correctness for the typical german or japanese user.

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg goof com      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |



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