[Vobject] Encoding Problems
Benjamin Bock
bb--py-vobjects at bockb.de
Sun Jan 29 10:21:32 CST 2006
Hi List,
I just stumbled across vobject b/c I wanted to update my contact's birthdays which are saved as events in an ical file
into the birthday fields of the contacts vcards.
One of my first steps was to print out the information from the file which went quite well when I did it in the
terminal. As soon as i tried to pipe or redirect it to another programm or into a file i got this:
Traceback (most recent call last):
File "showICalendar.py", line 69, in ?
cal.prettyPrint()
File "/usr/lib/python2.4/site-packages/vobject/base.py", line 405, in prettyPrint
line.prettyPrint(level + 1, tabwidth)
File "/usr/lib/python2.4/site-packages/vobject/base.py", line 405, in prettyPrint
line.prettyPrint(level + 1, tabwidth)
File "/usr/lib/python2.4/site-packages/vobject/base.py", line 240, in prettyPrint
print pre, self.name + ":", self.value
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe2' in position 2: ordinal not in range(128)
I replaced line 240 with the following (borrowed idea from __str__):
print pre, self.name + ":", unicode(self.value).encode('ascii', 'replace')
and all was fine again - but the new file was ascii, not unicode like the source :(
Could someone look into this? I have no clue, as I am completely new to Python
Thanks,
Benjamin
More information about the VObject
mailing list