This code currently doesn't work under Python 3. The to_unicode() function, and perhaps other things too.