Page 1 of 1

Unwanted blank character

Posted: Sun Nov 15, 2020 2:58 pm
by mariostg
I have a module in which I want to add the ability to save ics file that would look like so:

Code: Select all

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
LOCATION:123 Fake St\, New York\, NY
DESCRIPTION:This is my description
DTSTART:20201116T090000Z
DTEND:20201116T100000Z
SUMMARY:This is my summary
URL;VALUE=URI:http://example.com
DTSTAMP:20201115T144749Z
UID:5fb13f9575027
END:VEVENT
END:VCALENDAR
But instead I get a blank character on the first line:

Code: Select all

 BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
LOCATION:123 Fake St\, New York\, NY
DESCRIPTION:This is my description
DTSTART:20201116T090000Z
DTEND:20201116T100000Z
SUMMARY:This is my summary
URL;VALUE=URI:http://example.com
DTSTAMP:20201115T144749Z
UID:5fb13f9575027
END:VEVENT
END:VCALENDAR
I tired to narrow down the problem, but I am running out of ideas. So I tried this:

Code: Select all

header('Content-Type: text/calendar; charset=UTF-8');
header('Content-Disposition: attachment; filename=ics.ics');echo ".";die();
and even the above snippet I call with a hyperlink gives me a 2 byte file containing a space and the dot. Any suggestion what I should look for

Re: Unwanted blank character

Posted: Sun Nov 15, 2020 3:17 pm
by mariostg
Got it.

Code: Select all

$handlers = ob_list_handlers();
for ($cnt = 0; $cnt < sizeof($handlers); $cnt++) { ob_end_clean(); }
header('Content-Type: text/calendar; charset=UTF-8');
header('Content-Disposition: attachment; filename=ics.ics');echo "hello";die();
Odd because I don't need the first two lines when tried outside of the CMS.