fix encoding

This commit is contained in:
alejandro-campos 2020-06-24 17:54:41 +02:00
parent a81e4acbb7
commit 3a042c67f3
1 changed files with 11 additions and 6 deletions

View File

@ -378,15 +378,20 @@ our $THRRUN :shared = 1;
sub read_file($$) {
my ($path, $enc) = @_;
my $_FILE;
if ( $enc eq '' ) {
$enc = 'utf8';
if( !open($_FILE, "<", $path) ) {
# failed to open, return undef
return undef;
}
} else {
if( !open($_FILE, "<:encoding($enc)", $path) ) {
# failed to open, return undef
return undef;
}
}
my $_FILE;
if( !open($_FILE, "<:encoding($enc)", $path) ) {
# failed to open, return undef
return undef;
}
# Slurp configuration file content.
my $content = do { local $/; <$_FILE> };