fix encoding
This commit is contained in:
parent
a81e4acbb7
commit
3a042c67f3
|
@ -378,15 +378,20 @@ our $THRRUN :shared = 1;
|
||||||
sub read_file($$) {
|
sub read_file($$) {
|
||||||
my ($path, $enc) = @_;
|
my ($path, $enc) = @_;
|
||||||
|
|
||||||
|
my $_FILE;
|
||||||
|
|
||||||
if ( $enc eq '' ) {
|
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.
|
# Slurp configuration file content.
|
||||||
my $content = do { local $/; <$_FILE> };
|
my $content = do { local $/; <$_FILE> };
|
||||||
|
|
Loading…
Reference in New Issue