Re: gnome-vfs and encodings



On Sat, 2003-12-06 at 17:53, Murray Cumming Comneon com wrote:
> I'm changing regexxer
> http://regexxer.sourceforge.net/
> to use gnome-vfs instead of GIOChannel to read data, so it can use non-local
> file systems.
> 
> When using GIOChannel to read text from a file, we can use
> g_io_channel_set_encoding() to specify the text encoding, because not every
> file is UTF8 encoded.
> http://developer.gnome.org/doc/API/2.2/glib/glib-IO-Channels.html#g-io-chann
> el-set-encoding
> GIOChannel seems to be able to detect if the encoding is wrong.
> 
> Is there any equivalent for gnome_vfs_read(), or does gnome-vfs expect all
> text data to be in UTF8 format? Maybe the difference is that GIOChannel
> reads whole characters (1...n bytes) at a time, but gnome-vfs reads bytes.
> Hmm, I seem to be answering my own question, but I'll post anyway in case
> anyone has anything helpful to say.

No. gnome_vfs_read() is equivalent to the typical unix read() syscall.
It puts no requirements on the contents of the file/socket/whatever
you're reading from. In fact, its often used for binary files.

GIOChannel on the other hand is a buffering text-reader API which can be
extended to any underlying streams transport. You could easily make a
GIOChannel that reads from a GnomeVFSHandle if you want that.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl redhat com    alla lysator liu se 
He's a shy crooked assassin plagued by the memory of his family's brutal 
murder. She's an elegant bisexual vampire who dreams of becoming Elvis. They 
fight crime! 




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