Re: what is the encoding of returned string of gnome_file_entry_get_full_path()?



Hi Nickolay,

    I just filed one new bug: 321144.

    I wondering now what i should do if i want to fix this problem?  just need to send the patch to this alias?

Regards,
Yandong
Nickolay V. Shmyrev wrote:
Hi guys,

   I newly compiled the libgnomeui cvs, and when I run 
libgnomeui/test-gnome/test-gnome, I found below bug:

   1) run test-gnome which under test-gnome directory of libgnomeui
   2) click 'pixmap entry', then 'Pixmap Entry' dialog popup
   3) click 'Browse' Button, and select one picture file whose
filename 
is non-utf8 encoded

   result:
   1) The picture can not display on preview area.

   I run these steps on zh_CN.GB18030( one popular locale in China )
on 
solaris.

   Then I have a quick view on the source code, and found that:

   refresh_preview() use gnome_file_entry_get_full_path() to get the 
picture file full path, and gnome_file_entry_get_full_path() will
return 
the path in utf8 encoding, and then use gdk_pixbuf_new_from_file() to 
create pixbuf. As a result, gdk_pixbuf_new_from_file() can't find
this 
utf8-encoded file on disk, because the filename on disk it gb18030 
encoded, so can't preview picture file.

   The fix is pretty simple, we can use g_filename_from_utf8() to 
convert utf8 encoded filename to Glib encoded filename.

   What I wondering is that where we shoud put g_filename_from_utf8() 
in? it should in refresh_preview() or gnome_file_entry_get_full_path
()?

   If in refresh_preview(), then I guess we should modify all gnome 
codes where call gnome_file_entry_get_full_path().  So I think it
will 
be more better if we fix it in gnome_file_entry_get_full_path(), just 
like gtk_file_selection_get_filename() which return the selected 
filename in the Glib filename encoding.

   How do you think? any suggestions are welcome!

   I don't know if this alias is suitable for this or not, I hope
this 
is the right one.

Regards,
Yandong
    


Hello Yandong.

Thanks for very careful attention to details. Really you've found a bug.
That's clear that the problem is in function
gnome_file_entry_get_full_path() which mixes utf-8 filename from text
entry and filenames in GLIB encoding. If you look at this code:


  
	text = gtk_entry_get_text
		(GTK_ENTRY (gnome_file_entry_gtk_entry (fentry)));

	if (text == NULL || text[0] == '\0')
		return NULL;

    

	Here is text in utf-8

  
	file = _gnome_file_entry_expand_filename (text, fentry->default_path);
	if (file == NULL)
		return NULL;
    

Here is it already supposed to be in locale encoding.

Please search for a bug in our bugzilla (bugzilla.gnome.org) and file a
new one if there is no any. You can also create a patch that adds
conversion in the code above. We'll commit it certainly. 

The only thing I am wondering, why this problem stays unknown for so
long :)




  



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