pspp-dev
[Top][All Lists]
Advanced

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

Re: Problem with non-ascii filenames on a non utf-8 locale


From: John Darrington
Subject: Re: Problem with non-ascii filenames on a non utf-8 locale
Date: Sat, 15 May 2010 07:36:52 +0000
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Michel,

We have to be carefull converting between encodings.  If we inadvertently 
convert
to UTF8 twice, then bad things happen ...

It would be strange if any_reader_may_open was failing due to encoding issues, 
since that requires "native" encoding (aka "Glib encoding") which is exactly 
what
gtk_file_chooser_get_filename returns.

So far as I can see, your patch doesn't change anything, since name_utf8 is 
unused.
In any case, so far as I can see, all three functions (any_reader_may_open, 
psppire_window_load and open_syntax_window) expect the filename argument to be 
in "native" encoding.  

However, one thing that is clear: I need to go through all the functions in 
src/ui/gui
which accept filenames and add comments to explicitly state what encoding they 
expect.

If somebody who can reproduce this problem can give a detailed analysis --- or 
at least
a detailed description of the symptoms, then I think we can probably fix it.  

J'

On Fri, May 14, 2010 at 03:00:00AM -0300, Michel Boaventura wrote:
> I think I get what is going on here. PSPP doesn't open the .sav file,  
> but opens an empty syntax window.
> On psppire-data-window.c:457-463 there is:
>
> gchar *name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
>
> if (any_reader_may_open (name))
>   psppire_window_load (de, name);
> else
>   open_syntax_window (name);
>
> According to gtk docs  
> (http://library.gnome.org/devel/gtk/stable/GtkFileChooser.html#gtkfilechooser-encodings)
> gtk_file_chooser_get_filename doesn't return the filename on utf8.
> But it is passed to any_reader_may_open without any conversion.  
> any_reader_may_open can't identify any
> reader to the file, returns false and pspp thinks the file is a syntax file.
>
> The attached patch may fix it. Sadly I can't compile a windows version  
> now, because of a problem on my VM, so I
> can't test it. But at least on UTF8 profiles, nothing seems to be  
> changed with the patch.
>
> Michel

     diff --git a/src/ui/gui/psppire-data-window.c 
b/src/ui/gui/psppire-data-window.c
     index ae8a796..c5d1665 100644
     --- a/src/ui/gui/psppire-data-window.c
     +++ b/src/ui/gui/psppire-data-window.c
     @@ -454,15 +454,26 @@ open_window (GtkAction *action, PsppireWindow *de)
          {
          case GTK_RESPONSE_ACCEPT:
            {
     +        gchar *name_utf8;
     +        GError *err = NULL;
        gchar *name =
          gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
      
     +        name_utf8 = g_filename_to_utf8 (name, -1, NULL, NULL, &err);
     +        if ( NULL == name_utf8)
     +          {
     +            g_warning ("Cannot convert filename from filename encoding to 
UTF8: %s",
     +                       err->message);
     +            g_clear_error (&err);
     +          }
     +
              if (any_reader_may_open (name))
                psppire_window_load (de, name);
              else
                open_syntax_window (name);
      
        g_free (name);
     +        g_free (name_utf8);
            }
            break;
          default:

     _______________________________________________
     pspp-dev mailing list
     address@hidden
     http://lists.gnu.org/mailman/listinfo/pspp-dev


-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]