Coder Social home page Coder Social logo

Comments (5)

DJViking avatar DJViking commented on August 26, 2024

I found out how.
Setting parameter
address.setProperty("Chartset", "UTF-8");

from ez-vcard.

mangstadt avatar mangstadt commented on August 26, 2024

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

from ez-vcard.

DJViking avatar DJViking commented on August 26, 2024

Thanks. A much better approach than what I just found.

from ez-vcard.

DJViking avatar DJViking commented on August 26, 2024

On VCard V3.0 and V4.0 this produces an warning on validation
n.getParameters().setEncoding(Encoding.QUOTED_PRINTABLE);

W04 ENCODING parameter value ("QUOTED_PRINTABLE") is not supported by this vCard version.

It didn't like my Charset parameter either.

W06 Charset parameter is not supported by this vCard version.

Though I could just stick with V2.1

from ez-vcard.

mangstadt avatar mangstadt commented on August 26, 2024

That is correct. According to the specifications, only 2.1 supports quoted-printable encoding and the CHARSET parameter.

from ez-vcard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.