Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encoding newlines in iCal files

Tags:

icalendar

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 "\n" to represent a newline. This works great in Google Calendar, but Outlook just puts the literal "\n" characters in there.

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

like image 509
Eric Petroelje Avatar asked Mar 20 '09 16:03

Eric Petroelje


People also ask

What is Prodid in ICS?

Brief Description: Identifies the application that generated the iCalendar file. Importing to Calendar objects.

How do I import a link into iCal?

When your calendar is open, click on the + sign in the Other Calendars section of the screen. Next, click on Import. Select the previously downloaded file from your computer and click on Open. Finally, click on Import and you're all done!

What is an iCal URL?

An iCalendar link, often shortened to “an iCal”, is a link to another calendar. iCal is an open standard for exchanging calendar and scheduling information between users and computers; it has been around since the late 1990s.


Video Answer


1 Answers

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

The correct way to do it is to use "\n" 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 \n. Since most languages treat that as an escape sequence meaning a newline character, you probably need to use the string \\n in your code.

like image 159
Eric Petroelje Avatar answered Sep 20 '22 03:09

Eric Petroelje