in reply to Another Unicode/emoji question
As it is a Festive Break 🎄 I've had the opportunity to test this calendar import and find out what is really going on...
I created a simple test script to generate a single calendar entry from noon to 2pm tomorrow. The day after the ICS feed is accessed.
#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use strict; use warnings; use lib "$ENV{'DOCUMENT_ROOT'}/../lib"; use open ":std", ":encoding(UTF-8)"; use Site::Utils; my $template = Template->new(INCLUDE_PATH => $Site::Variables::temp +late_path); $data{'format'} = 'calendar' unless $data{'format'} eq 'plain'; print "Content-type: text/$data{'fomat'}; charset=utf-8;\n\n"; #print "\x{feff}"; # BOM my ($date, $uid) = $dbh->selectrow_array("SELECT DATE_FORMAT(NOW() + I +NTERVAL 1 DAY, '%Y%m%d'), DATE_FORMAT(NOW(), '%Y-%j-%H%i%s')"); if ($data{'template'}) { $template->process("admin/google/dogface.tt", $vars)or die $templa +te->error; exit; } print<<"END"; BEGIN:VCALENDAR VERSION:2.0 PRODID:Pawsies Calendar 1.0//EN CALSCALE:GREGORIAN METHOD:PUBLISH BEGIN:VEVENT SUMMARY:\x{1f436} Dog Face Test UID:DFT$uid\@pawsies.uk SEQUENCE:1 DTSTAMP:${date}T120000 DTSTART:${date}T120000 DTEND:${date}T140000 END:VEVENT END:VCALENDAR END
The module Site::Utils provides the database handle $dbh and splits the HTTP query string and puts it into %data.
If the BOM is included, Google Calendar doesn't display the entry at all. With the BOM omitted, the entry is displayed.
But, if we print the ICS data directly from the script, the 🐶 emoji is displayed correctly. If we use Template to handle the printing, instead of 🐶 we get the literal \x{1f436}... So, it appears to be Template that is not printing the Unicode characters.
Try it here:
Printing from script
Printing with Template
Of course, knowing where the problem exists is different to being able to solve it...
Do you have any experience of printing Unicode using Template?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Template and Unicode (was: Re: Another Unicode/emoji question)
by haj (Vicar) on Dec 28, 2023 at 23:31 UTC | |
|
Re: Template and Unicode (was: Re: Another Unicode/emoji question)
by choroba (Cardinal) on Dec 28, 2023 at 22:42 UTC |