singing the praises of unicode and codecs
Steven Bethard
steven.bethard at gmail.com
Fri Dec 10 13:43:17 EST 2004
More information about the Python-list mailing list
Fri Dec 10 13:43:17 EST 2004
- Previous message (by thread): tibia error in apache2
- Next message (by thread): Compiling Python 2.4 extensions with free VC++ Toolkit
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I just wanted to thank Python for making encodings so easy!
I recently discovered that one of the tools I use stores everything in
UTF-8, and so I was getting some off-by-one errors because I was
treating things as strings. I added
def __unicode__(self):
return str(self).decode('utf-8')
to the base object in the hierarchy, and wrapped my popen calls with
readers and writers:
file_in, file_out, file_err = _os.popen3(self.command)
file_in = codecs.getwriter(self.encoding)(file_in)
file_out = codecs.getreader(self.encoding)(file_out)
file_err = codecs.getreader(self.encoding)(file_err)
and voilĂ ! Everything works perfect!
Thank you Python!
Steve
- Previous message (by thread): tibia error in apache2
- Next message (by thread): Compiling Python 2.4 extensions with free VC++ Toolkit
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list