On 1/22/07, John Cupitt <[EMAIL PROTECTED]> wrote: > Hi Olivier, > > On 1/22/07, Olivier Ramare <[EMAIL PROTECTED]> wrote: > > -- The file I read has nothing other than ascii > > characters (letters even from a-zA-Z and punctuation). > > -- But gtk complains with enumerables > > --------------------------------------------------------------------------------- > > Gtk-CRITICAL **: gtk_text_buffer_emit_insert: > > assertion `g_utf8_validate (text, len, NULL)' failed > > -------------------------------------------------------------------------------- > > I think you must have a non-ASCII character in there somewhere. I do > (almost) this without problems. Perhaps your read routine is pasting > the EOF (-1) character into the string by mistake?
It could be also that len is possitive and NULL is reached before reading len bytes. (http://developer.gnome.org/doc/API/2.4/glib/glib-Unicode-Manipulation.html#g-utf8-validate) BTW, and just to save some time, you could consider to use g_file_get_contents() to read an entire file. (http://developer.gnome.org/doc/API/2.2/glib/glib-File-Utilities.html#g-file-get-contents) > > How about testing your characters before you insert them? Plain ASCII > is in the range 0 to 0x7f, so try: > > for (i = 0; i < len; i++) > if ((unsigned char) text[i] > 0x7f) > printf ("non-ASCII at index %d\n", i); > gtk_text_buffer_set_text (buffer, text, len); > > John > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > Cheers _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list