NareshK
NareshK

Reputation: 43

How to use line breaks in an item description when adding to Google Calendar

I am using the google calendar api to add events to a calendar. Everything is working fine, but there seems to be an issue if I try to use line breaks in the event description. \n is not working in the link

I would like the description of the event to read:

Hello
this is the description for add to calander

which as a string is:

"Hello\nthis is the description for add to"

Here is the link I've been trying to use:

http://www.google.com/calendar/render?details=Hello\n this is the description for add to calander&trp=true&action=TEMPLATE&text=Text here&sprop Dname=Subjet here&location=Location Here&pli=1&sf=true&output=xml

Upvotes: 3

Views: 4674

Answers (1)

Matthias Linder
Matthias Linder

Reputation: 76

You have to URI encode the '\n' character. The character '\n' has an ASCII value of 0x0A (in hex), and can so be encoded as %0A. You also might want to escape other characters like spaces. The link below will achieve what you are trying to do:

http://www.google.com/calendar/render?details=Hello%0Athis+is+the+description+for+add+to+calender&trp=true&action=TEMPLATE&text=Text+here&sprop+Dname=Subject+here&location=Location+Here&pli=1&sf=true&output=xml

If you want to find the appropriate ascii characters, have a look at the hex values in this ASCII table.

Upvotes: 4

Related Questions