VCALENDAR file with newlines in DESCRIPTION field

Hopefully if anyone else has this problem, they’ll find this post. If you’re attempting to output some data in a MySQL database as a VCALENDAR file that is viewable in Apple Calendar or Outlook or whatever, an incorrect newline character in any field can make that event not show up (or make the entire file invalid in some applications).

What you’re looking for is an escaped newline character. Newlines are stored in MySQL as \n. You want to escape that character in your ics file, so replace \n with \\n. While you’re at it, it’s a good idea to replace ; with \; and , with \,. There may also be others, but those are the ones I’ve found so far.

About Scott Allen

Scott Allen is from Indianapolis, Indiana. He has been working with HTML, CSS, PHP, & MySQL since the late 1990s, and has extensive experience in database design and development, server-side scripting, content management, and front-end user experience in both client services and in-house settings. You can connect with Scott on Twitter or via email.
This entry was posted in Code, Tech and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *