Error using GTK

When trying to use this gtk code:

import gtk
tv = gtk.TextView()
b = tv.get_buffer()
t = "Let check this out.\x00"
b.set_text(t)

I get this error:

GtkWarning: gtk_text_buffer_emit_insert: assertion `g_utf8_validate (text, len, NULL)' failed

The text is generated automatically here, which I showed, for example. I wanted to put this line in a text buffer, but I cannot. Help me out with this.

+4
source share
3 answers

I believe this is due to the weird built-in 0-byte at the end of the line t(part \x00).

I don't think you can expect / require GTK + to support binary data in GtkTextBuffer, it just requires the text to be in UTF-8. Remove the false 0-byte.

, , Python n, C GTK +, , '\0', .

, fast_validate_len() ( g_utf8_validate()) 0-, .

+1

g_utf8_validate documentation , false NUL. , NUL UTF-8.

-, : gssize max_len, nul-terminated? , . , . NUL .

+1

, , , , .

, C \x00, , . , C , . pygtk C- muckery . , \x00 . , .

+1

Source: https://habr.com/ru/post/1589366/


All Articles