Re: Mozilla selections question

Havoc Pennington <[email protected]>
Newsgroups gmane.comp.mozilla.devel.gtk
Message-ID <[email protected]>
Philip <[email protected]> writes: 
> My next question is.. what is the best way to convert this UCS2 string to
> a format that I can use in Gnome/Gtk+ applications? (example : I
> want to
> show the string in a GtkTextView/GtkText widget.)

guint16 *ucs2 = selection_data->data;
int i;
GString *str;

str = g_string_new (NULL);
i = 0;
while (i < selection_data->length / 2)
  {
    g_string_append_unichar (str, ucs2[i]);

    ++i;
  }

return g_string_free (str, FALSE);

Or something like that.

> OpenOffice.org also has a "text/html" target. This results in a correct
> string. So won't this create an incosistent protocol? In application a it
> gives me an UCS2 string, in application b it's a normal one :-\

Yes, this means you are fucked and one of the apps is broken. Just
accept not working with the broken one, and file a bug to get it
fixed.

Havoc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.