Re: Can someone please comment on this short program


Am Mittwoch, den 14.12.2005, 13:30 +0100 schrieb Alexander Larsson:
> On Wed, 2005-12-14 at 07:52 +0100, Matthias Kaeppler wrote:
> > .. lots of stuff...
> I'm not sure where the confusion is. I can't talk for the c++ bindings,
> but for gnome-vfs itself the rule is:
>   * file: URIs have no inherent encoding
> None, nada, zilch. They are the filename as stored on disk, escaped into
> a uri. As such, they are essentially escaped byte strings, the only
> limit being that zero bytes and '/' bytes are not allowed. This is a
> direct result of the fact that unix filenames have no encoding, and is
> nothing we can anything do about in gnome-vfs.

I see... that is good to know :)

> In glib there are some functions for handling the encoding of filenames,
> namely g_filename_to/from_utf8. These are mainly for displaying and
> entering filenames in a UI, since the UI always uses utf8 for all
> strings which might not be right for a filename. These functions use
> G_BROKEN_FILENAMES and G_FILENAME_ENCODING env vars to determine what
> encoding to use for the filenames. However, valid files can still have
> names that are not in this encoding, and to be able to e.g. open or
> rename such a file gnome-vfs must allow a uri point to it, and such a
> uri would not be in the encoding specified by G_FILENAME_ENCODING (nor
> would it necessarily be utf8).

So basically "if you construct gnome_vfs_uri's, don't bother with
g_filename_to/from_utf8 but just leave the filename alone and pass it
as-is" ?

So Matthias problem was caused just by the actual source code being in a
different encoding than the filename encoding on the mountpoint?

> You just have to be very careful about your string encodings. I'd
> recommend using hex escapes when specifying a non-ascii string in C
> source code.

with append_file_name, does that do the escaping by its own (i.e. would
it be escaped twice when following your suggestion) ? (and what about
append_string, append_path)

I'm sure this is written down somewhere, excuse me for being blind :)

> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>  Alexander Larsson                                            Red Hat, Inc 


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