Re: GError location filename as wide chars
- From: Kevin Ryde <user42 zip com au>
- To: gtk-perl-list gnome org
- Cc: Quentin Sculo <squentin free fr>
- Subject: Re: GError location filename as wide chars
- Date: Thu, 26 Feb 2009 08:18:19 +1100
Quentin Sculo <squentin free fr> writes:
FileChooserDialog
If the docs are to be believed gtk_file_chooser_get_filename() returns
bytes, though it's marked as a gchar* return. Eg. foo.pl below in a
latin1 locale, click on browse then click on the y-dieresis file gives
Malformed UTF-8 character (overflow at 0x1806ade8, byte 0x00, after start byte 0xff) in subroutine entry
at /usr/lib/perl/5.10/Data/Dumper.pm line 190.
And a printf in the XS shows gtk_file_chooser_get_filename() returned a
bare '\xFF' byte.
But if you then press return in the entry box with that same file, it
comes out of gtk_file_chooser_get_filename() as actual utf8, where I
might have expected latin1. (This is with gtk 2.12.11 and glib 2.18.4
at least.) So I'm more confused than ever ...
impossible to use Gtk2::Gdk::Pixbuf->new_from_file with these files,
Is it gperl_filename_from_sv() which is to blame? Or the return from
the chooser?
For gdk_pixbuf_new_from_file() it does look like it'd be much better off
passing a raw byte string straight through, since the first thing that
func does is simply fopen().
(As opposed to currently where gperl_filename_from_sv() does an
"upgrade" with SvPVutf8() then immediately downgrade again with
g_filename_from_utf8().)
use strict;
use warnings;
use Gtk2 '-init';
use Data::Dumper;
{ open my $out, '>', "\x{FF}" or die; print $out "hello\n"; }
my $dialog = Gtk2::FileChooserDialog->new
('Try Save', undef, 'save',
'gtk-save' => 'accept',
'gtk-cancel' => 'cancel');
$dialog->signal_connect
(response => sub {
my $filename = $dialog->get_filename;
print "utf8: ",(utf8::is_utf8($filename) ? "yes" : "no"),"\n";
print Data::Dumper->new([$filename],['filename'])->Dump;
});
$dialog->show;
Gtk2->main;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]