George_H - 2011-10-12

Cardme by default reads and writes VCards in standard RFC2426 mode which
strictly adheres to the RFC Standard. For cardme to support and work with many
programs there have been some compatibility modes built in. These modes are
turned on / off in 2 places.

  1. VCardEngine for reading
  2. VCardWriter for writing

These compatibility modes need to be set before writing or parsing, like so

VCardEngine vcardEngine = new VCardEngine();
vcardEngine.setCompatibilityMode(CompatibilityMode.MS_OUTLOOK);

For writing you can set a compatibility mode and a folding scheme.

VCardWriter writer = new VCardWriter();
writer.setCompatibilityMode(CompatibilityMode.MS_OUTLOOK);
writer.setFoldingScheme(FoldingScheme.MS_OUTLOOK);

Of course you can intermix the modes to achieve whatever result you wish. With
the writer and engine you can change the modes per vcard. Since is done
because when cardme writes or reads a vcard it is done via the
VCardEngine.parse() method and then VCardWriter.setVCard() method. So the code
snip below shows how we do such a thing.

VCardEngine vcardEngine = new VCardEngine();
vcardEngine.setCompatibilityMode(CompatibilityMode.MS_OUTLOOK);
String myOutlookCard = vcardEngine.parse("/home/george/test.vcf");

vcardEngine.setCompatibilityMode(CompatibilityMode.RFC2426);
String myNormalCard = vcardEngine.parse("/home/george/test2.vcf");

VCardWriter writer = new VCardWriter();
writer.setCompatibilityMode(CompatibilityMode.MS_OUTLOOK);
writer.setFoldingScheme(FoldingScheme.MS_OUTLOOK);
writer.setVCard(myOutlookVCard);
String outlookCard = writer.buildVCardString();

writer.setCompatibilityMode(CompatibilityMode.RFC2426);
writer.setFoldingScheme(FoldingScheme.RFC2426);
writer.setVCard(myNormalVCard);
String normalCard = writer.buildVCardString();

Now whats the difference between the different compatibility modes? Some may
affect you and some may not. See the list below:

MS_OUTLOOK


1) The parameter type "WORK" is added to the URL feature.

2) Encoding parameter type uses BASE64 instead of B.

3) Base64 encoded text start on a new line and end with a new line (v2.1
style)

4) Folds base64 encoded text at 72 characters instead of 75.

5) Compensates for missing mandatory semi-colons in name (N type) when
parsing.

6) Compensates for missing = sign delimiting parameter types in PHOTO, LOGO,
SOUND and KEY types when parsing.

I_PHONE


1) Encoding parameter type uses BASE64 instead of B.

2) Compensates for missing = sign delimiting parameter types in PHOTO, LOGO,
SOUND and KEY types when parsing.

MAC_ADDRESS_BOOK


1) Folds lines at 76 characters instead of 75.

2) Base64 encoded text start on a new line and end with a new line (v2.1
style)

3) Folds base64 encoded text at 72 characters instead of 75.

4) Does not include the ENCODING parameter type for PHOTOs.

5) Compensates for missing = sign delimiting parameter types in PHOTO, LOGO,
SOUND and KEY types when parsing.

KDE_ADDRESS_BOOK


1) Uses escaped commas in the CATEGORIES feature when there is more than one
category. The RFC-2426 explicitly states "One or more text values separated by
a COMMA character"

2) Escapes commas in CATEGORIES feature when writing vcard.

Should anyone happen to find an application that is acting quirky, please
inform the developer of that application to fix their code. If they are really
stubborn or big (Like Microsoft, apple ..etc) then post it has a feature
request.