[Vobject] vobject.base.ParseError:, need help

Jeffrey Harris jeffrey at osafoundation.org
Mon Jan 7 16:44:20 CST 2008


Hello,

> The code i used is:
> 
> text = text.replace(';ENCODING=QUOTED-PRINTABLE','')
> text = quopri.decodestring(text)
> card = vobject.readOne(text)
> 
> What I want to get is the name in a vcard, can you help me?

vobject's support for quoted-printable (and vcard 2.1 in general) is
fairly limited, but it should work for your example file.

So, don't do anything with the quoted-printable at all.  Just do:

card = vobject.readOne(text)

vobject will decode the quoted-printable data automatically.  Then, you
should see:

>>> card.n.value
'\xe5\x90\xb4;\xe5\x86\x9b\xe4\xbf\x9d'

This is a raw Python string, vobject doesn't automatically decode the
utf-8 data if the utf-8 is quoted-printable encoded (but it ought to,
feel free to file a bug at bugzilla.osafoundation.org for this to be
fixed).  To get the unicode value of the name, do:

>>> card.n.value.decode('utf8')
u'\u5434;\u519b\u4fdd'

Sincerely,
Jeffrey


More information about the VObject mailing list