Fixed handling of Japanese encoding by policy.

This commit is contained in:
Junichi Satoh 2020-06-11 18:06:16 +09:00
parent 9a65b61e25
commit e75de8a1a5

View File

@ -46,6 +46,7 @@ use constant MOD232 => 2**32;
use constant POW232 => 2**32; use constant POW232 => 2**32;
# UTF-8 flags deletion from multibyte characters when files are opened. # UTF-8 flags deletion from multibyte characters when files are opened.
use open IN => ":utf8";
use open OUT => ":utf8"; use open OUT => ":utf8";
use open ":std"; use open ":std";
@ -374,11 +375,15 @@ our $THRRUN :shared = 1;
################################################################################ ################################################################################
## Reads a file and returns entire content or undef if error. ## Reads a file and returns entire content or undef if error.
################################################################################ ################################################################################
sub read_file { sub read_file($$) {
my $path = shift; my ($path, $enc) = @_;
if ( $enc eq '' ) {
$enc = 'utf8';
}
my $_FILE; my $_FILE;
if( !open($_FILE, "<", $path) ) { if( !open($_FILE, "<:encoding($enc)", $path) ) {
# failed to open, return undef # failed to open, return undef
return undef; return undef;
} }