Re: Coding systems ?



On 1/22/07, John Cupitt <jcupitt gmail com> wrote:
Hi Olivier,

On 1/22/07, Olivier Ramare <Olivier Ramare univ-lille1 fr> 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]