[Vobject] saving unicode vcard

Anil replicase at gmail.com
Mon Jun 2 11:01:40 CDT 2008


Any comments anyone?

Also, maybe allowQP should be isQP?
I guess I need to read in the file and search for quoted-printable and
if found call readComponents with allowQP...

On 5/31/08, Anil <replicase at gmail.com> wrote:
> Jeffrey,
>
>  Oh, it seems the problem I am having is because I am using
>  allowQP=True when I read
>  the vcard back in (as per the bug/email from a few days ago).
>
>  If I don't set that kw, it works fine.
>
>  Soo, how do I handle this? I had this before:
>
>  v = vobject.readComponents(myfile.value, allowQP=True)
>  for vcard in v:
>    ...
>
>  What if there are multiple different formats in the file, but if I
>  have to explicitly specify allowQP,
>  that'd break.
>
>  Do I need to read in the file and see if in the file there is
>  "quoted-printable", than I should
>  do allowQP, if not, I wouldn't pass it in.
>
>  Couldn't readComponents automatically detect the format of the
>  component being read?
>
>
>
>
>
>  On Sat, May 31, 2008 at 1:25 PM, Jeffrey Harris
>  <jeffrey at osafoundation.org> wrote:
>  > Hi Anil,
>  >
>  >> I am reading some data from a database in UTF8. I convert the data
>  >> into unicode. I want to save it to a vcard file. Should this data be
>  >> written as Unicode or UTF8?
>  >>
>  >> I am doing something like this now:
>  >>
>  >>             f = codecs.open(fname, "w", 'utf-8')
>  >>             f.write(j.serialize().decode('utf-8'))
>  >>             f.close()
>  >
>  > I really need to tweak this, but right now, serialize *always* encodes
>  > as utf-8, you don't have any choice in the matter.
>  >
>  > Note that the serialize method can take a stream as an argument, in
>  > which case it will serialize directly to the stream.
>  >
>  > So what you're doing above should work, but it'd be simpler to just do:
>  >
>  > f = open(fname, "w")
>  > j.serialize(f)
>  >
>  > That should put utf-8 encoded data in fname.
>  >
>  > Yes, UTF-8 contains escape characters for data that isn't 7-bit ASCII.
>  > All in all, I'm not sure what's going wrong for you.
>  >
>  > Sincerely,
>  > Jeffrey
>  > _______________________________________________
>  > VObject mailing list
>  > VObject at lists.skyhouseconsulting.com
>  > http://lists.skyhouseconsulting.com/mailman/listinfo/vobject
>  >
>


More information about the VObject mailing list