Comment 8 for bug 833747

Revision history for this message
Daniel Manrique (roadmr) wrote :

There are two changes to be made here:

- First, checkbox/variable.py, the UnicodeVariable class now uses the 'ascii' encoder by default (decoder in this case I think), so if the string to be converted to unicode contains non-ascii characters, the call to unicode will throw an exception, which was the originally observed problem. Fix is to explicitly specify the encoding to use while reading the string. I used utf-8.

- Second, when loading strings into a GtkTextBuffer, it expects utf8 encoding, otherwise it "eats" characters and the string gets truncated. So we check to see if the passed text is a unicode instance and, if so, it gets explicitly re-encoded as utf8, thus keeping the TextBuffer happy.

I'll link a branch with these fixes in a couple of minutes.