Re: Glib::filename_to_unicode bug?
- From: Quentin Sculo <squentin free fr>
- To: gtk-perl-list gnome org
- Subject: Re: Glib::filename_to_unicode bug?
- Date: Sat, 17 Apr 2010 00:16:47 +0200
On Fri, 2010-04-16 at 12:19 -0700, Dave Hayes wrote:
I guess I should ask this: If I have files on the disk that have
invalid
UTF-8 characters in them, do I have a way to get Glib to operate on
files who's names are invalid UTF-8 strings? Is Glib really forcing me
to rename this file to operate on it? :)
There are some bugs in the gtk/glib bindings, some functions
auto-convert their arguments or return_values to utf8 strings if they
don't have the utf8 flag on, which is of course wrong for filenames.
For filename arguments, one not-pretty work-around that works for some
functions is using _utf8_on (from the Encode package) to forcefully turn
the utf8 flag on for the string, so that it is not converted to utf8.
Another work-around is to use a similar function that works with uri,
when there is one.
For functions that return a filename, some simply do not work with
non-utf8 filenames.
When you want to display a filename, you should use
Glib::filename_display_name() as Kevin suggested.
A few examples :
Gtk2::Image->new_from_file and Gtk2::Gdk::Pixbuf->new_from_file don't
work with invalid utf8, even with the _utf8_on trick. A work-around is
opening the file yourself, and feeding it to a pixbuf_loader.
in Gtk2::FileChooserDialog:
- get_filename works (return a string with its utf8 flag
turned on even if not valid utf8)
- get_preview_filename : die with invalid utf8
get_preview_uri can be used instead
- set_filename works
- set_current_folder, doesn't work with invalid utf8
set_current_folder_uri can be used instead
Quentin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]