[Vobject] unicode in vcards
jeffrey at osafoundation.org
Wed Dec 12 20:04:04 CST 2007
> This last line throws this exception:
> <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode
> characters in position 29-31: ordinal not in range(128)
> I think j.serialize() returns the data in unicode, but how come this
> exception is being thrown when saving to that file?
If you want to write unicode to a file, you need to encode the unicode.
There are various ways to do this, the easiest, I think, is:
f = codecs.open('test.txt', 'w', 'utf-8')
More information about the VObject