[Gpa-commits] r1026 - trunk/src

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 8 08:55:53 CEST 2010


Author: werner
Date: 2010-10-08 08:55:52 +0200 (Fri, 08 Oct 2010)
New Revision: 1026

Modified:
   trunk/src/ChangeLog
   trunk/src/clipboard.c
Log:
utf-8 fix (untested)


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2010-05-06 11:15:16 UTC (rev 1025)
+++ trunk/src/ChangeLog	2010-10-08 06:55:52 UTC (rev 1026)
@@ -1,3 +1,7 @@
+2010-10-06  Werner Koch  <wk at g10code.com>
+
+	* clipboard.c (file_created_cb): Fallback to Latin-1.
+
 2010-05-06  Werner Koch  <wk at g10code.com>
 
 	* gpadatebutton.c: Include i18n.h.

Modified: trunk/src/clipboard.c
===================================================================
--- trunk/src/clipboard.c	2010-05-06 11:15:16 UTC (rev 1025)
+++ trunk/src/clipboard.c	2010-10-08 06:55:52 UTC (rev 1026)
@@ -270,12 +270,31 @@
   if (! suc)
     {
       gchar *str;
+      gsize *len;
+
       str = g_strdup_printf ("Error in operation result:\n"
-			     "No valid UTF-8 at position %i.",
+			     "No valid UTF-8 at position %i.\n"
+                             "Assuming Latin-1 encoding instead.",
 			     ((int) (end - item->direct_out)));
       gpa_window_error (str, GTK_WIDGET (clipboard));
       g_free (str);
-      return;
+
+      str = g_convert (item->direct_out, item->direct_out_len,
+                       "UTF-8", "ISO-8859-1",
+                       NULL, &len, NULL);
+      if (str)
+        {
+#ifdef G_OS_WIN32
+          dos_to_unix (str, &item->direct_out_len);
+#endif
+          
+          gtk_text_buffer_set_text (clipboard->text_buffer, str, len);
+          g_free (str);
+          return;
+        }
+      gpa_window_error ("Error converting Latin-1 to UTF-8",
+                        GTK_WIDGET (clipboard));
+      /* Enough warnings: Try to show even with invalid encoding.  */
     }
 
 #ifdef G_OS_WIN32



More information about the Gpa-commits mailing list