Stephen Kennedy wrote:

Loading non-utf8 or non 7 bit ascii into a textbuffer gives this
error, and no text is displayed in the textview.

How can I check if this has happened (the buffer still reports
the correct length) and what should I do if it does happen? Ask the user for a fallback encoding? text = unicode( text, "latin1" )?

With GTK 2.0, you are responsible for passing valid UTF-8 data to gtk functions, just as with 1.2 you were responsible for passing data in the user's locale's encoding. PyGTK makes things easier by allowing you to pass unicode strings, and have them handled appropriately.

By calling locale.getlocale(), you get a (language_code, encoding) tuple that you can use to work out what encoding user data is probably in. You can then use this to convert to UTF-8 (or a unicode string).

James.

--
Email: [EMAIL PROTECTED] | Linux.conf.au http://linux.conf.au/
WWW: http://www.daa.com.au/~james/ | Jan 22-25 Perth, Western Australia.



_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Reply via email to