Question

I see some inconsistency in vCard 4.0 RFC 6350 new line escaping rules. Section 3.4 says:

NEWLINE (U+000A) characters in values MUST be encoded by two characters: a BACKSLASH followed by either an 'n' (U+006E) or an 'N' (U+004E).

I assume that I should replace not only the LF (U+000A) character, but CRLF sequence. This is how it was in vCard 3.0 RFC 2426 and the difference from vCard 2.1.

Should I replace CRLF sequence or only LF character according to vCard 4.0 specification?

Was it helpful?

Solution

In vCard 4.0, the newline escape sequence is \n. If the local operating system uses CRLF as its newline sequence, the CR and LF characters are both replaced with a single \n.

When parsing a vCard, the \n should be replaced with whatever the local operating system's newline sequence is.

OTHER TIPS

This only applies to ESCAPE sequences! That is, when you want to put new lines in property values, you have to write "\n". When it comes to line breaks in the vcard-code itself, the RFC states that you should use CRLF (0x0D0A), so your should not replace any "real" line break characters in your vcard file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top