David Nečas writes:
> So if we leave out all the redundant things (and add at
> least basic sanity checks), this will remain:
>
> GtkTextBuffer *textbuffer;
> gchar *buf;
> const gchar *errpos;
> GError *err = NULL;
> gsize n;
>
> if (g_file_get_contents(filename, &buf, &n, &err)) {
> if (g_utf8_validate(buf, n, &errpos)) {
> textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textarea));
> gtk_text_buffer_set_text(textbuffer, buf, n);
> }
> else
> g_printerr("Invalid byte at position %d\n", (gint)(errpos - buf));
> g_free(buf);
> }
> else {
> g_printerr("Cannot read %s: %s\n", filename, err->message);
> g_clear_error(&err);
> }
>
> This works, and if it doesn't it will tell you what's wrong.
Thanks for bearing with me, but I just discovered that the documents aren't
UTF-8, but actually ISO-10646-UCS-2 (opening from Kedit). Now, I am again
struggling to get that to show up.
Thanks.
Kumar
_______________________________________________
gtk-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-list