# HG changeset patch # User Ethan Blanton # Date 1083650927 0 # Node ID ab5a46dd132ac37edf1c902ef3fe6d8f5af10903 # Parent db80183f251c4a476c33106bf29e60a3d872e28e [gaim-migrate @ 9637] Copy/paste fixes for UCS-2 encoded selections committer: Tailor Script diff -r db80183f251c -r ab5a46dd132a ChangeLog --- a/ChangeLog Mon May 03 18:34:08 2004 +0000 +++ b/ChangeLog Tue May 04 06:08:47 2004 +0000 @@ -22,6 +22,7 @@ * Gtk2.0 compatibility fixes (Tim Ringenbach) * Updated and standardized blist signals (Gary Kramlich) * More doxygen fixes (Jonathan Champ) + * Copy/paste encoding fixes (Joe Marcus Clarke) version 0.77 (04/22/2004): New Features: diff -r db80183f251c -r ab5a46dd132a src/gtkimhtml.c --- 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; } }