[Vobject] vCard 2.1 behaviour

Jeffrey Harris jeffrey at skyhouseconsulting.com
Mon Oct 29 23:00:26 CDT 2012


Hi Martin,

Yes, vCard 2.1 is a sad situation.

The fact that the encoding (including the line wrapping!) is different means that a 2.1 parser is a significant chunk of work.

The behaviors were designed with varying syntax/serialization such as 2.1 v.s 3.0 in mind, but behaviors haven't historically controlled the content-line layer, which meant we never finished making 2.1 usable. All in all, there would need to be sizable changes to support this.

Still, this seems to be the most requested feature in vobject, so if you have enthusiasm, supporting 2.1 would help people a lot.

The registerBehavior functionality should work as you intuited, although there have occasionally been bugs where behaviors are not automatically assigned, so your mileage may vary.

On a different note, I apologize for my long absence from the mailing list. I am unfortunately currently contractually obligated to not work on vobject, so I'd like to invite interested parties to take on ownership of vobject. If you're interested, send me an email! Additionally, we really need some updated documentation, so anyone interested in writing up a tutorial would also be welcomed.

- Jeffrey

> Apart from the encoding, which in vCard 3.0 is proper standardised
> Unicode+Base64, vCard 2.1 is ASCII and ASCII-encoded, where the
> encoding and charset are specified with the ENCODING and CHARSET
> variables as part of the properties of the field, e.g.
> 
>  ADR;ENCODING=QUOTED-PRINTABLE;CHARSET=ISO-8859-1:Meinestra=DFe
> 
> I think (hope) that vObjects store data in Unicode. It should not be
> hard to write up proper encoding/decoding for serialisation and
> reading, but I can't quite figure out where to start.
> 
> encode/decode are class methods of the object behaviour, and this
> makes sense. However, there are also field behaviours, e.g.
> NameBehavior.
> 
> Is it true that by calling e.g.
> 
>  registerBehavior(NameBehavior, 'N')
> 
> I am telling vObject to apply this behaviour to the value of
> all 'N' fields, and if no specific behaviour is registered for
> a field, then a default behaviour, VCardTextBehavior, is used?
> 
> So for a 2.1 vCard, I would define a class NameBehavior2_1, call
> registerBehaviour(NameBehavior2_1, 'N2_1') and then configure the
> VCard2_1 behaviour's knownChildren to contain
> 
>  N: (1,1,'N2_1')
> 
> right?
> 
> If the above holds, then vobject is truly well designed.
> 
> To recap, taking the above line, and assuming for a minute that ADR
> needs special handling for vCards 2.1:
> 
>  ADR;ENCODING=QUOTED-PRINTABLE;CHARSET=ISO-8859-1:Meinestra=DFe
> 
> The behaviour for the ADR field registered it AdrBehaviour. Now the
> following steps happen on readOne():
> 
>  1. AdrBehaviour.decode receives the ContentLine object holding the
>     above, decoding it to the internal representation (Unicode?)
> 
>  2. AdrBehaviour.transformToNative is called to turn the value into
>     an internal object, an Address in this case.
> 
> On serialize(), the following happens:
> 
>  1. AdrBehaviour.transformFromNative is called, which turns the
>     object's value into vCard representation
>     (;;Street;ZIP;State;Country)
> 
>  2. AdrBehaviour.encode is called to turn the entire ContentLine
>     into vCard2.1-compatible text, e.g. encoding it to Base64 or
>     QuotedPrintable.
> 
>  3. AdrBehaviour.serialize is called to serialize the ContentLine.
> 
> Thanks for any thoughts an input, which should greatly facilitate
> coding this up in one go.
> 
> -- 
> martin | http://madduck.net/ | http://two.sentenc.es/
> 
> "i sometimes think that god
> in creating man
> somewhat overestimated his ability."
>                                                        -- oscar wilde
> 
> spamtraps: madduck.bogus at madduck.net
> _______________________________________________
> VObject mailing list
> VObject at lists.skyhouseconsulting.com
> http://lists.skyhouseconsulting.com/mailman/listinfo/vobject



More information about the VObject mailing list