[Xfce4-commits] <parole:master> Fix playlist storage in UTF-8.

Sean Davis noreply at xfce.org
Wed Jan 23 03:58:01 CET 2013


Updating branch refs/heads/master
         to 896a6127b6d8be738ac8f77f2223f5543f324490 (commit)
       from 17c775f39484400fc56c129fcf8ed7aabb8e90ab (commit)

commit 896a6127b6d8be738ac8f77f2223f5543f324490
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Tue Jan 22 21:56:11 2013 -0500

    Fix playlist storage in UTF-8.

 src/misc/parole-pl-parser.c |   37 +++++++++++++++++++++++++++++++++----
 1 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/src/misc/parole-pl-parser.c b/src/misc/parole-pl-parser.c
index d846ac0..e7f992f 100644
--- a/src/misc/parole-pl-parser.c
+++ b/src/misc/parole-pl-parser.c
@@ -56,6 +56,20 @@ typedef struct
     
 } ParoleParserData;
 
+static gchar*
+parole_filename_to_utf8(const gchar* filename)
+{
+    gsize read, written;
+    
+    gchar *utf8;
+    gchar *tmp = g_strdup(filename);
+    tmp = g_strconcat(tmp, "\0", NULL);
+    
+    utf8 = g_filename_to_utf8(tmp, -1, &read, &written, NULL);
+    g_free(tmp);
+    return utf8;
+}
+
 static void
 parole_xspf_xml_start (GMarkupParseContext *context, const gchar *element_name,
 		       const gchar **attribute_names, const gchar **attribute_values,
@@ -486,18 +500,33 @@ parole_pl_parser_save_m3u (FILE *f, GSList *files)
     guint len;
     guint i;
     
+    gchar *display_name = NULL;
+    gchar *file_name = NULL;
+    
     fputs ("#EXTM3U\n\n", f);
     
     len = g_slist_length (files);
     
     for ( i = 0; i < len; i++)
     {
-	ParoleFile *file;
-	file = g_slist_nth_data (files, i);
-	fprintf (f, "#EXTINF:-1,%s\n", parole_file_get_display_name (file));
-	fprintf (f, "%s\n\n", parole_file_get_file_name (file));
+	    ParoleFile *file;
+	    file = g_slist_nth_data (files, i);
+	    display_name = g_strdup(parole_file_get_display_name (file));
+	    file_name = parole_filename_to_utf8(parole_file_get_file_name (file));
+	
+	    if (display_name && file_name)
+	    {
+	        fprintf (f, "#EXTINF:-1,%s\n", display_name);
+	        fprintf (f, "%s\n\n", file_name);
+	    }
     }
     
+    if (display_name)
+        g_free(display_name);
+        
+    if (file_name)
+        g_free(file_name);
+    
     return TRUE;
 }
 


More information about the Xfce4-commits mailing list