Mercurial > pidgin
diff src/gtkimhtml.c @ 8869:ab5a46dd132a
[gaim-migrate @ 9637]
Copy/paste fixes for UCS-2 encoded selections
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Tue, 04 May 2004 06:08:47 +0000 |
parents | d7b5fbc451da |
children | 1ab2a9c17f4a |
line wrap: on
line diff
--- a/src/gtkimhtml.c Mon May 03 18:34:08 2004 +0000 +++ b/src/gtkimhtml.c Tue May 04 06:08:47 2004 +0000 @@ -689,7 +689,6 @@ static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data) { char *text; - guint16 c; GtkIMHtml *imhtml = data; GtkTextIter iter; GtkIMHtmlOptions flags = GTK_IMHTML_NO_NEWLINE; @@ -761,14 +760,14 @@ memcpy(text, selection_data->data, selection_data->length); } - memcpy (&c, text, 2); - if (c == 0xfeff) { - /* This is UCS2 */ - char *utf8 = g_convert(text+2, selection_data->length - 2, "UTF-8", "UCS-2", NULL, NULL, NULL); + if (selection_data->length >= 2 && + (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) { + /* This is UCS-2 */ + char *utf8 = g_convert(text, selection_data->length, "UTF-8", "UCS-2", NULL, NULL, NULL); g_free(text); text = utf8; if (!text) { - gaim_debug_warning("gtkimhtml", "g_convert failed in paste_received_cb\n"); + gaim_debug_warning("gtkimhtml", "g_convert from UCS-2 failed in paste_received_cb\n"); return; } }