Bug - UTF8
- Fixed bug in the handling of UTF8 JSON data from holidata.net, when update-holidays.pl when decoding and writing files.
This commit is contained in:
@@ -270,6 +270,8 @@
|
||||
+ Fixed problem with non-UTC defaults for "TZ" (thanks to Owen Clarke).
|
||||
+ Removed use of Lua API call that is deprecated in 5.1 and removed from 5.2
|
||||
(thanks to Michal Vyskocil).
|
||||
+ Fixed problem where update-holidays.pl did not properly handle UTF8 JSON
|
||||
data.
|
||||
|
||||
------ old releases ------------------------------
|
||||
|
||||
|
||||
@@ -45,6 +45,13 @@ if ($@)
|
||||
exit 1;
|
||||
}
|
||||
|
||||
eval "use Encode";
|
||||
if ($@)
|
||||
{
|
||||
print "Error: You need to install the Encode Perl module.\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Command line options, argument validation.
|
||||
my $help;
|
||||
my $locale;
|
||||
@@ -147,8 +154,8 @@ print "\n",
|
||||
|
||||
# Without data, cannot proceed.
|
||||
my $data;
|
||||
$data .= $data_current if defined $data_current;
|
||||
$data .= $data_next if defined $data_next;
|
||||
$data .= decode ('utf-8', $data_current) if defined $data_current;
|
||||
$data .= decode ('utf-8', $data_next) if defined $data_next;
|
||||
exit (1) if !defined $data || $data eq '';
|
||||
|
||||
# Filter the holidays according to @regions.
|
||||
@@ -170,8 +177,7 @@ for my $holiday (split /\n/ms, $data)
|
||||
}
|
||||
|
||||
# Overwrite the file.
|
||||
if (open my $fh, '>', $file)
|
||||
#if (open my $fh, '>:encoding(UTF-8)', $file)
|
||||
if (open my $fh, '>:utf8', $file)
|
||||
{
|
||||
print $fh
|
||||
"# International Holiday Data provided by Holidata.net\n",
|
||||
|
||||
Reference in New Issue
Block a user