fix encoding
This commit is contained in:
parent
2133126182
commit
27770b91da
|
@ -374,17 +374,25 @@ our $THRRUN :shared = 1;
|
|||
################################################################################
|
||||
## Reads a file and returns entire content or undef if error.
|
||||
################################################################################
|
||||
sub read_file($$) {
|
||||
sub read_file($;$) {
|
||||
my ($path, $enc) = @_;
|
||||
|
||||
if ( $enc eq '' ) {
|
||||
$enc = 'utf8';
|
||||
}
|
||||
|
||||
my $_FILE;
|
||||
if( !open($_FILE, "<:encoding($enc)", $path) ) {
|
||||
# failed to open, return undef
|
||||
return undef;
|
||||
|
||||
if (!defined($enc)) {
|
||||
if( !open($_FILE, "<", $path) ) {
|
||||
# failed to open, return undef
|
||||
return undef;
|
||||
}
|
||||
} else {
|
||||
if ( $enc eq '' ) {
|
||||
$enc = 'utf8';
|
||||
}
|
||||
|
||||
if( !open($_FILE, "<:encoding($enc)", $path) ) {
|
||||
# failed to open, return undef
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
|
||||
# Slurp configuration file content.
|
||||
|
|
Loading…
Reference in New Issue