Fix encoding issues in HTML report files
authorDan Scott <dscott@laurentian.ca>
Tue, 17 Nov 2015 17:11:19 +0000 (12:11 -0500)
committerDan Scott <dscott@laurentian.ca>
Fri, 25 May 2018 21:25:46 +0000 (17:25 -0400)
Opening the files without the utf-8 encoding pragma resulted in
corrupted UTF8 output.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/reporter/clark-kent.pl

index 72edf18..d31ede6 100755 (executable)
@@ -486,6 +486,7 @@ sub build_html {
        my $r = shift;
 
        my $index = new FileHandle (">$file") or die "Cannot write to '$file'";
+       open(my $index, ">:encoding(utf-8)", "$file") or die "Cannot write to '$file'";
 
        my $tdata = OpenSRF::Utils::JSON->JSON2perl( $r->{report}->{template}->{data} );
        
@@ -556,7 +557,7 @@ sub build_html {
 
        if ($r->{html_format}) {
                # create the raw output html file
-               my $raw = new FileHandle (">$file.raw.html") or die "Cannot write to '$file.raw.html'";
+               open(my $raw, ">:encoding(utf-8)", "$file.raw.html") or die "Cannot write to '$file.raw.html'";
                print $raw "<html><head><meta charset='utf-8'><title>$$r{report}{name}</title>";
 
                print $raw <<'          CSS';
@@ -582,7 +583,7 @@ sub build_html {
                }
                print $raw '</body></html>';
        
-               $raw->close;
+               close($raw);
        }
 
        # Time for a pie chart
@@ -626,7 +627,7 @@ sub build_html {
        # and that's it!
        print $index '</body></html>';
        
-       $index->close;
+       close($index);
 }
 
 sub draw_pie {