[cairo] Basic cairomm questions

Murray Cumming murrayc at murrayc.com
Mon Aug 11 05:13:55 PDT 2008


On Fri, 2008-08-08 at 12:47 -0700, Carl Worth wrote:
> > - As a graphics library, I realize encodings and Unicode aren't
> >    really a big concern to Cairo, but is there any definitive
> >    approach to this?  Again, using the filename passed to the
> >    PdfSurface constructor, what encoding/codepage is that
> >    expected to be in?  Current runtime?  UTF8?  ISO-8859-1?
> >    [ All our text handling is in Unicode, so I'll need to
> >      address this issue anywhere I'm interfacing with relevant
> >      Cairo code. ]
> 
> This is an excellent question, and not cairomm-specific. You might
> actually want to raise this again in a separate thread with a
> descriptive subject for this issue. (I'm guessing that Owen, with his
> glib experience, might have some comments here.)
> 
> I don't recall what discussions/decisions we might have made on this
> topic in the past, but the functions that accept a string for a filename
> don't appear to have anything specific documented for them. (On Linux,
> it's easy to just say that the string is a byte sequence that will be
> handed to open(2), but we might want a better cross-platform story than
> that---I don't know.)

We are talking about the encoding of the filepath not the encoding of
the file contents, right?

For GTK+, the rule is generally that the filepath is in whatever
encoding the file system should use (it can be different depending on
both the OS and the drive/server, I think). That's why gtkmm uses
std::string for filepath parameters instead of Glib::ustring, to make
that clearer. GtkFileChooser will provide the raw filepath without
converting it to UTF-8.

However, when your UI asks the user to manually enter a filepath
(outside of the GtkFileChooser), or when the UI tries to show a
representation of a path, UTF-8 is generally involved, so there are
functions such as g_filename_to_utf8(), g_filename_from_utf8(). These
hide the actual encoding, which is nice. For instance:
http://library.gnome.org/devel/glib/stable/glib-Character-Set-Conversion.html#g-filename-to-utf8 

I assume that cairo follows the same logic.

-- 
Murray Cumming
murrayc at murrayc.com
www.murrayc.com
www.openismus.com




More information about the cairo mailing list