Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
469 views
in Technique[技术] by (71.8m points)

icalendar - Encoding newlines in iCal files

I'm trying to figure out how to encode newlines in the DESCRIPTION part of an iCal file in such a way that they will import properly into Outlook, Google Calendar and the Apple Calendar.

The original code I inherited used "=0D=0A" with a quoted-printable encoding, which works great in Outlook, but not in Google Calendar.

The spec seems to say you should use " " to represent a newline. This works great in Google Calendar, but Outlook just puts the literal " " characters in there.

Is there a way you've done this that will work consistently accross calendaring systems?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

OK, looks like I'm answering my own question.

The correct way to do it is to use " " for line breaks. Outlook did not recognize this because I had "ENCODING=quoted-printable" on the description. Once I removed that, Outlook displayed the new lines correctly.

Also, to get the file to open correctly in Apple iCal, you need to use "VERSION:2.0" for the file version. If you use "VERSION:1.0", it will tell you it can't read the file (even though it conforms to the 1.0 spec).

NOTE: As others have mentioned, the file actually has to contain the literal string . Since most languages treat that as an escape sequence meaning a newline character, you probably need to use the string \n in your code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...