changeset 27832:b8f28a250c22

prepending BOM to selection data produces garbage in almost all cases.
author Yoshiki Yazawa <yaz@honeyplanet.jp>
date Tue, 06 May 2008 07:51:03 +0000
parents 61a7929a97b5
children 1dd0e007514d
files pidgin/gtkimhtml.c
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkimhtml.c	Thu May 01 15:24:43 2008 +0000
+++ b/pidgin/gtkimhtml.c	Tue May 06 07:51:03 2008 +0000
@@ -932,16 +932,33 @@
 		} else
 			text = html_clipboard;
 
+#if 0
+		/* faulty! it tries to add BOM wrongly. furthermore,
+		 * TARGET_HTML is used in somewhere else than mozilla
+		 * so that blindly adding BOM produces unexpected
+		 * garbage in those places. --yaz */
+
 		/* Mozilla asks that we start our text/html with the Unicode byte order mark */
 		str = g_string_append_unichar(str, 0xfeff);
 		str = g_string_append(str, text);
 		str = g_string_append_unichar(str, 0x0000);
 		selection = g_convert(str->str, str->len, "UTF-16", "UTF-8", NULL, &len, NULL);
-		gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE), 16, (const guchar *)selection, len);
+		gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE),
+				       16, (const guchar *)selection, len);
 		g_string_free(str, TRUE);
 #else
+		/* firefox no longer needs BOM. do it simply. --yaz */
+		selection = NULL;
+		g_string_free(str, TRUE);
+
+		gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE),
+				       8, (const guchar *)text, strlen(text));
+#endif
+
+#else /*_WIN32 */
 		selection = clipboard_html_to_win32(html_clipboard);
-		gtk_selection_data_set(selection_data, gdk_atom_intern("HTML Format", FALSE), 8, (const guchar *)selection, strlen(selection));
+		gtk_selection_data_set(selection_data, gdk_atom_intern("HTML Format", FALSE),
+				       8, (const guchar *)selection, strlen(selection));
 #endif
 		g_free(selection);
 	} else {