[Vobject] using latin-1

Jeffrey Harris jeffrey at osafoundation.org
Thu Jul 5 12:21:33 CDT 2007


Hello Francois,

> What is the proper way of handling latin-1 encoded text in a vcard? I
> keep getting UnicodeDecodeErrors when calling serialize.

Generally speaking, inside a library you want to treat all text as
unicode, this is how vobject works.  If you read a vcard encoded in
latin-1 or some utf variant, vobject will decode the stream into unicode
before parsing.  Other encodings need to be decoded explicitly before
parsing or you'll get unicode errors.

You can't print unicode code points that don't map to ASCII from Python,
so instead of looking at vcard.serialize(), you want to view
vcard.serialize().encode('utf-8')

For more about unicode and vcards, see:

http://lists.skyhouseconsulting.com/pipermail/vobject/2007-July/000077.html

If that doesn't solve your problem, let me know.

Sincerely,
Jeffrey


More information about the VObject mailing list