g_filename_to_utf8



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.

-- 
I speak for myself, not my employer
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]