mangstadt / ez-vcard

A vCard parser library for Java
Other
399 stars 92 forks source link

Encoding.QUOTED_PRINTABLE to upper case #56

Closed ekorn closed 8 years ago

ekorn commented 8 years ago

in the Windows 10 Contact Application everything that is marked with "ENCODING=quoted-printable" in lower case is misinterpreted. When it is changed to ENCODING=QUOTED-PRINTABLE in upper case it works fine. I guess it is more a problem of the Win 10 Contact App.

mangstadt commented 8 years ago

Nico,

Thank you for the report. Can you post an example of a vCard that Windows 10 doesn't like? I want to make sure there's nothing else wrong with the vCard. Thank you.

ekorn commented 8 years ago

Sure I uploaded two one working one not

2859_Dipl_Paed_Pedrayk_Konsovkow_Verwaltung.txt 2859_Dipl_Paed_Pedrayk_Konsovkow_Verwaltung_win10_error.txt

mangstadt commented 8 years ago

Thank you. Is "Windows 10 Contact Application" the actual name of the application?

mangstadt commented 8 years ago

Fixed in e2a4dd3318e7bf846f83e925029c2a2512be3803. Thanks for reporting this.

Call VCardWriter.setTargetApplication() like so:

VCard vcard = new VCard();
FormattedName fn = vcard.setFormattedName("Dipl. Päd. Konsovkow");
fn.getParameters().setEncoding(Encoding.QUOTED_PRINTABLE);

VCardWriter writer = new VCardWriter(System.out, VCardVersion.V3_0);
writer.setTargetApplication(TargetApplication.WINDOWS_10_CONTACTS);
writer.write(vcard);
writer.close();

Output:

BEGIN:VCARD
VERSION:3.0
PRODID:ez-vcard 0.9.11-SNAPSHOT
FN;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:Dipl. P=C3=A4d. Konsovkow
END:VCARD
mangstadt commented 8 years ago

Addendum: I decided to instead change the parameter value on the Encoding.QUOTED_PRINTABLE object. This is solution is not only simpler, but also a little bit more spec-compliant because the 2.1 specification does not say anything about this parameter value being case-insensitive. I also converted the "BASE64", "7BIT", and "8BIT" parameter values to uppercase for the same reason.

See: a960585e34cad8267248382bdd26781609e88835