-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding charset encoding to elements in VCard #106
Comments
I found out how. |
To just add a CHARSET parameter to a property: vcard.getStructuredName().getParameters().setCharset("UTF-8"); If you are still having trouble, you can try encoding the property value in quoted-printable encoding. My understanding is that this is the most widely supported technique amongst vCard readers. Quoted-printable encoding allows for non-ASCII characters to be included in a property value, no matter what character set the vCard as a whole uses. By default, ez-vcard uses UTF-8 when encoding a value in quoted-printable encoding (the CHARSET parameter is automatically added when quoted-printable encoding is used). StructuredName n = new StructuredName();
n.setFamily("Solskjær");
n.setGiven("Åge");
n.getParameters().setEncoding(Encoding.QUOTED_PRINTABLE);
VCard vcard = new VCard(VCardVersion.V2_1);
vcard.setStructuredName(n);
vcard.write(System.out);
//outputs: N;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:Solskj=C3=A6r;=C3=85ge |
Thanks. A much better approach than what I just found. |
On VCard V3.0 and V4.0 this produces an warning on validation
It didn't like my Charset parameter either.
Though I could just stick with V2.1 |
That is correct. According to the specifications, only 2.1 supports quoted-printable encoding and the CHARSET parameter. |
In order to support special characters on iPhone we had to (with VCard v2.1) add
Charset=UTF-8
to each elements.WIthout it tthe special characters did not display properly on iPhone. It works fine on Android with and without the Charset.
N;CHARSET=UTF-8:Solskjær;Åge
ADR;WORK;CHARSET=UTF-8:Address with ÆØÅ Special Characters;1234;Norway
I could not find any way to add this with ez-vcard.
The text was updated successfully, but these errors were encountered: