Re: g_filename_to_utf8



Robert Brady <robert suse co uk> writes:

> Whilst playing with GtkCalendar, I discovered that g_filename_to_utf8 and
> g_utf8_to_filename haven't been properly implemented for non-Win32
> platforms, the attached patch rectifies this.

Would it make sense to have an environment variable to control this?
That is, something like G_UTF8_FILENAMES, to allow people without
UTF-8 locale support to still have GLib handle files as UTF-8.
(A slight generalization would be G_FILENAME_ENCODING, to allow
maximally flexible handling.)

(I consider non-UCS/non-tagged filenames a really bad idea and almost
feel that we should have an environment variable with the opposite
meaning - something like G_BROKEN_FILENAMES)

Regards,
                                        Owen

> Index: gstrfuncs.c
> ===================================================================
> RCS file: /cvs/gnome/glib/gstrfuncs.c,v
> retrieving revision 1.45
> diff -u -r1.45 gstrfuncs.c
> --- gstrfuncs.c	2000/09/29 13:37:01	1.45
> +++ gstrfuncs.c	2000/10/23 01:00:21
> @@ -47,6 +47,9 @@
>  #include <windows.h>
>  #endif
>  
> +#include "gconvert.h"
> +#include "gunicode.h"
> +
>  /* do not include <unistd.h> in this place since it
>   * inteferes with g_strsignal() on some OSes
>   */
> @@ -1331,8 +1334,14 @@
>    return result;
>  
>  #else
> +
> +  char *charset;
> +
> +  if ( g_get_charset (&charset))
> +    return g_strdup (opsysstring);
>  
> -  return g_strdup (opsysstring);
> +  return g_convert (opsysstring, strlen (opsysstring), 
> +		    "UTF-8", charset, NULL, NULL, NULL);
>  
>  #endif
>  }
> @@ -1442,8 +1451,14 @@
>    return result;
>  
>  #else
> +
> +  char *charset;
> +
> +  if ( g_get_charset (&charset))
> +    return g_strdup (utf8string);
>  
> -  return g_strdup (utf8string);
> +  return g_convert (utf8string, strlen (utf8string), 
> +		    charset, "UTF-8", NULL, NULL, NULL);
>  
>  #endif
>  }




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