Re: problem reading a non-english file



Hi,

Ruben Porras <nahoo82 telefonica net> writes:

> The following pice (obviously it has other widgets, but I think they
> aren't relevant) of code works right with an english file, but when the
> file has caracters as "ñ" fails sayin the error
> 
> (gtklilo:11289): Gtk-CRITICAL **: file gtktextbuffer.c: line 532
> (gtk_text_buffer_insert_at_cursor): assertion `text != NULL' failed

you absolutely need to feed the TextBuffer with UTF-8 encoded text.

> GtkWidget *view_en;
> GIOChannel *manpage_en;
> GtkTextBuffer *buffer_en;
> 
> view_en = gtk_text_view_new();
> buffer_en = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view_en));
> 
> g_io_channel_read_to_end(manpage_en, &cadena_en, NULL, NULL);	
> gtk_text_buffer_insert_at_cursor(buffer_en, cadena_en,-1);

If you know the encoding of the text you are reading thru the
IoChannel you can use g_io_channel_set_encoding() and it will
convert to UTF-8 (provided that iconv supports the conversion).
To get a list of supported encodings, try 'iconv -l'.


Salut, Sven



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