[pygtk] utf8 validating string
John Ehresman
jpe at wingware.com
Sat Dec 1 06:24:39 WST 2007
Yann Leboulanger wrote:
>>>> import gtk
>>>> tv = gtk.TextView()
>>>> b = tv.get_buffer()
>>>> t = "Let's check this out.\x00"
>>>> u = unicode(t, 'utf-8')
>>>> b.set_text(t)
> __main__:1: GtkWarning: gtk_text_buffer_emit_insert: assertion
> `g_utf8_validate (text, len, NULL)' failed
>
> but b.set_text(u) works ... is it the way to go?
Your mistake might be the final '\x00'. Is there a reason you're
including it? Python handles \x00 in strings, but gtk (& most C libs)
probably doesn't.
Cheers,
John
More information about the pygtk
mailing list