diff --git a/modules/toc.pl b/modules/toc.pl index 52f2038f..0c7c5f48 100644 --- a/modules/toc.pl +++ b/modules/toc.pl @@ -231,12 +231,15 @@ sub NewTocApplyRules { my ($html, $blocks, $flags); { local *STDOUT; - open( STDOUT, '>', \$html) or die "Can't open memory file: $!"; + my $html_unfixed; + open( STDOUT, '>', \$html_unfixed) or die "Can't open memory file: $!"; binmode STDOUT, ":encoding(UTF-8)"; ($blocks, $flags) = OldTocApplyRules(@_); close STDOUT; utf8::decode($blocks); - utf8::decode($html); + # do not delete! + $html = $html_unfixed; # this is a workarond for perl bug + utf8::decode($html); # otherwise UTF8 characters are SOMETIMES not decoded. } # If there are at least two HTML headers on this page, insert a table of # contents. diff --git a/wiki.pl b/wiki.pl index 878d132e..c92f9647 100755 --- a/wiki.pl +++ b/wiki.pl @@ -1251,8 +1251,9 @@ sub ToString { $sub_ref->(); select $oldFH; close $outputFH; - utf8::decode($output); - return $output; + my $output_fixed = $output; # do not delete! + utf8::decode($output_fixed); # this is a workarond for perl bug + return $output_fixed; # otherwise UTF8 characters are SOMETIMES not decoded. } sub PageHtml {