banshee r4882 - in trunk/banshee: . src/Libraries/Migo/Migo.Net



Author: gburt
Date: Wed Jan  7 18:41:59 2009
New Revision: 4882
URL: http://svn.gnome.org/viewvc/banshee?rev=4882&view=rev

Log:
2009-01-07  Gabriel Burt  <gabriel burt gmail com>

	* src/Libraries/Migo/Migo.Net/AsyncWebClient.cs: Patch from BenjamÃn
	Valero Espinosa fixing bug with not handling the XML encoding attribute
	properly; RSS feeds in non-UTF-8 should now parse correctly (BGO #538224)


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs

Modified: trunk/banshee/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs
==============================================================================
--- trunk/banshee/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs	(original)
+++ trunk/banshee/src/Libraries/Migo/Migo.Net/AsyncWebClient.cs	Wed Jan  7 18:41:59 2009
@@ -781,7 +781,21 @@
             case DownloadType.String:
                 string s;
                 try {
-                    s = Encoding.GetString (resultPtr);
+                    s = Encoding.GetString (resultPtr).TrimStart ();
+
+                    // Workaround if the string is a XML to set the encoding from it
+                    if (s.StartsWith("<?xml")) {
+                        string auxStr = "encoding=";
+                        int startIndex = s.IndexOf (auxStr) + auxStr.Length + 1;
+                        int endIndex = s.IndexOf ('\"', startIndex);
+                        string encodingStr = s.Substring (startIndex, endIndex - startIndex);
+                        try {
+                            Encoding enc = Encoding.GetEncoding (encodingStr);
+                            if (!enc.Equals (Encoding)) {
+                                s = enc.GetString (resultPtr);
+                            }
+                        } catch (ArgumentException) {}
+                    }
                 } catch {
                     s = String.Empty;
                 }



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