Closed hamburml closed 6 months ago
I think I misread it and I also found an old issue https://github.com/mangstadt/ez-vcard/issues/3. Should it be
BEGIN:VCARD
VERSION:2.1
X-PRODID:ez-vcard 0.12.1
N:urml;hamb
FN:hamburml
NOTE;ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8:THISIS=0D=0AANOTE
END:VCARD
The output your example code produced is correct.
Newline characters have special meaning in vCards. So, when you add a newline character to a property's value, it has to be escaped in some way.
Because you are serializing to version 2.1, the way it escapes the newline is by encoding the property value in quoted-printable encoding. This converts the newline character to "=0A".
Regarding the use of UTF-8: When encoding a value in quoted-printable encoding, a character set must be specified. UTF-8 is used by default.
Okay, thanks. This is very strange... If the vcard is used by an android phone (pixel 7 for example) the Note is "THISIS=0ANOTE" and not with a line break... I thought it was due to the encoding, but I was probably wrong...
Right, the line break is converted to "=0A".
The application that consumes the vCard should know how to decode it back into a line break character. :)
I am still a bit puzzled to be honest... Why is there a = before 0A? edit What I try to achieve is a value inside the note property with several new lines.
Hello!
Here are the notes!
This is another information inside the note, which is dynamically generated on the server. Maybe the sentence is longer than 75 characters so automatic folding must happen according due the spec.
Have a good day.
It has a = because that's how quoted-printable encoding knows it's an encoded character. :)
Hm okay, that makes sense, didnt know that. I use the generated vcard and embed it inside a qr code. When I scan the qr code with my pixel phone the =0A isnt decoded when using the stock camera app. When I try it with a samsung phone it works like expected. If I use a qr code scanner app from the play store it also works on the pixel phone. So it looks like the stock camera app has some issues decoding that.
Thanks!
If you serialize the vCard as version 3.0 or 4.0, it encodes the newlines differently (using backslash escaping instead of quoted-printable encoding). The stock camera app might like that better.
According to https://datatracker.ietf.org/doc/html/rfc2425#section-5.8.1 after a CRLF the content starts in the next line. This is not the case anymore.
Here is a simple example: https://github.com/hamburml/ez-vcard-example/blob/master/src/main/java/de/hamburml/Main.java
This is the output
I would expect
And is it correct to add UTF-8 automatically?