Unwanted blank character

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
mariostg
Forum Members
Forum Members
Posts: 12
Joined: Wed Apr 08, 2020 12:10 pm

Unwanted blank character

Post 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
mariostg
Forum Members
Forum Members
Posts: 12
Joined: Wed Apr 08, 2020 12:10 pm

Re: Unwanted blank character

Post 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.
Post Reply

Return to “Modules/Add-Ons”