I'm having trouble inserting events using the v3 Google Calendar API (PHP).
If the event description contains a symbol, such as the £ pound sign, the event is created on the calendar, but the description remains empty. This seems to apply to all characters outside the original 7-bit character codes (ASCII codes 0-127).
Using the htmlentities function, I can replace all instances of the pound sign: £
This is normal if the user uses the web version of Google Calendar, but mobile applications do not convert this back to the pound sign.
This is a pretty big problem since events are often copied and pasted from Microsoft Word, which use quotes other than ascii.
Is there a specific encoding method that will work around this? I am currently using UTF-8 encoding in a MySQL database and PHP scripts.
I use the following code to create an event:
function buildGoogleEvent($title,$description,$start_time,$end_time,$location) {
$event = new Google_Event();
$event->setSummary($title);
$event->setLocation($location);
$event->setDescription(htmlentities($description, ENT_NOQUOTES, 'utf-8'));
$start_time_atom = str_replace(" ", "T", $start_time);
$end_time_atom = str_replace(" ", "T", $end_time);
$start = new Google_EventDateTime();
$start->setDateTime($start_time_atom);
$start->setTimeZone('Europe/London');
$event->setStart($start);
$end = new Google_EventDateTime();
$end->setDateTime($end_time_atom);
$end->setTimeZone('Europe/London');
$event->setEnd($end);
return $event;
}
And this code inserts an event:
$createdEvent = $service->events->insert($google_calendar_id, $event);
Sitting on this for quite some time, so any help is appreciated! My version of PHP is 5.5.4.