--- gst-plugins-0.8.7~/gst/tags/gstid3tag.c	2004-07-27 19:14:02 +0300
+++ gst-plugins-0.8.7/gst/tags/gstid3tag.c	2005-01-24 16:02:21 +0200
@@ -23,9 +23,12 @@
 #include "config.h"
 #endif
 
+
 #include "gsttageditingprivate.h"
 #include <stdlib.h>
 #include <string.h>
+#include <enca.h>
+#include <locale.h>
 
 static const gchar *genres[] = {
   "Blues",
@@ -245,28 +248,51 @@
 {
   gsize bytes_read;
   gchar *conv;
-
-  /* FIXME: better charset detection? */
+  
+  EncaAnalyser analyser;
+  EncaEncoding encoding;
+  
   if (g_utf8_validate (start, size, NULL)) {
-    conv = g_strchomp (g_strndup (start, size));
+    	conv = g_strchomp (g_strndup (start, size));
+	g_printerr("Not converted!\n");  
   } else {
-    conv = g_locale_to_utf8 (start, size, &bytes_read, NULL, NULL);
-    if (bytes_read != size) {
-      g_free (conv);
-      conv =
-          g_convert (start, size, "UTF-8", "ISO-8859-1", &bytes_read, NULL,
-          NULL);
-      if (bytes_read != size) {
-        g_free (conv);
-        return;
+	gchar *temp;
+    temp = g_strchomp (g_strndup (start, size));
+	if (temp == "") { 
+		g_printerr("Word is Null\n");
+		return; 
+	}
+	analyser = enca_analyser_alloc(g_strndup (setlocale(LC_ALL,""), 2));
+	encoding = enca_analyse(analyser, temp, strlen(temp));
+	
+	if (!enca_charset_is_known(encoding.charset)) {
+		conv = g_convert(start, size, "UTF8", "CP1251", &bytes_read, NULL, NULL);
+		g_printerr("Enca error: %s\n", enca_strerror(analyser,
+													enca_errno(analyser))); 
+	} else {
+      	conv = g_convert(start,
+						size, 
+						"UTF8", 
+						enca_charset_name(encoding.charset, 
+											ENCA_NAME_STYLE_ICONV),
+						&bytes_read, 
+						NULL,
+						NULL);
+    }
+	  enca_analyser_free(analyser);  
+	  g_free (temp);
+	  	
+      if (bytes_read != size) {	
+		g_printerr("Conversation error!\n");  
+		g_free (conv);
+		return;
       }
     }
-    conv = g_strchomp (conv);
-  }
+    
   if (conv[0] != '\0') {
-    gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, tag, conv, NULL);
+	gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, tag, conv, NULL);
   }
-  g_free (conv);
+  g_free (conv);  	
 }
 
 /**
@@ -314,7 +340,9 @@
     gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE,
         gst_tag_id3_genre_get (data[127]), NULL);
   }
-
+  gchar *str;
+  gst_tag_list_get_string (list,GST_TAG_TITLE, &str);
+    
   return list;
 }
 
