diff --git a/lib/Biber/CodePage.pm b/lib/Biber/CodePage.pm index 993846814..2aa3c84ad 100644 --- a/lib/Biber/CodePage.pm +++ b/lib/Biber/CodePage.pm @@ -4,6 +4,7 @@ use strict; use warnings; use parent qw(Exporter); our @EXPORT = qw( decode_CS_system encode_CS_system get_CS_system + is_Unicode_system set_CP_Win_console set_CS_defaults set_STD_encodings ); our @EXPORT_OK = qw( get_CS_log string_analysis ); @@ -92,6 +93,12 @@ sub get_CS_log() { #-------------------------- +sub is_Unicode_system() { + return (uc($CS_system) eq 'UTF-8') || (uc($CS_system) eq 'CP65001'); +} + +#-------------------------- + sub set_STD_encodings($) { # Set coding scheme for STDOUT, STDERR & STDIN. my $CS = shift; @@ -249,7 +256,4 @@ END { # Don't worry about what to do with STDOUT, etc; it should be unimportant from here. } - - - 1; diff --git a/lib/Biber/Utils.pm b/lib/Biber/Utils.pm index fbb7980b9..fc7201bda 100644 --- a/lib/Biber/Utils.pm +++ b/lib/Biber/Utils.pm @@ -171,9 +171,8 @@ sub slurp_switchr { my ($filename, $encoding) = @_; my $slurp; $encoding //= 'UTF-8'; - if ($^O =~ /Win/ and not Biber::Config->getoption('winunicode')) { + if ($^O =~ /Win/ and not is_Unicode_system() ) { require Win32::Unicode::File; - # JCC ?? Removed NFC my $fh = Win32::Unicode::File->new('<', $filename); $fh->binmode(":encoding($encoding)"); # 100MB block size as the loop over the default 1MB block size seems to fail for @@ -196,9 +195,8 @@ sub slurp_switchr { sub slurp_switchw { my ($filename, $string) = @_; - if ($^O =~ /Win/ and not Biber::Config->getoption('winunicode')) { + if ($^O =~ /Win/ and not is_Unicode_system() ) { require Win32::Unicode::File; - # JCC ?? Removed NFC my $fh = Win32::Unicode::File->new('>', $filename); $fh->binmode(':encoding(UTF-8)'); $fh->write($string); @@ -206,7 +204,6 @@ sub slurp_switchw { $fh->close; } else { - # JCC ?? Removed NFC File::Slurper::write_text($filename, $string); } return; @@ -394,9 +391,8 @@ sub locate_data_file { sub file_exist_check { my $filename = shift; - if ($^O =~ /Win/ and not Biber::Config->getoption('winunicode')) { + if ($^O =~ /Win/ and not is_Unicode_system() ) { require Win32::Unicode::File; - # JCC ?? Add test without NF mapped filename. if (Win32::Unicode::File::statW($filename)) { return $filename; } @@ -408,7 +404,6 @@ sub file_exist_check { } } else { - # JCC ?? Add test without NF mapped filename. if (-e "$filename") { return $filename; } @@ -431,9 +426,8 @@ sub file_exist_check { sub check_empty { my $filename = shift; - if ($^O =~ /Win/ and not Biber::Config->getoption('winunicode')) { + if ($^O =~ /Win/ and not is_Unicode_system() ) { require Win32::Unicode::File; - # JCC ?? Remove NFC return (Win32::Unicode::File::file_size($filename)) ? 1 : 0; } else { @@ -449,9 +443,8 @@ sub check_empty { sub check_exists { my $filename = shift; - if ($^O =~ /Win/ and not Biber::Config->getoption('winunicode')) { + if ($^O =~ /Win/ and not is_Unicode_system() ) { require Win32::Unicode::File; - # JCC ?? Remove NFC return Win32::Unicode::File::statW($filename) ? 1 : 0; } else { diff --git a/testfiles/Unicode-tests-preserved-NF.zip b/testfiles/Unicode-tests-preserved-NF.zip index 48c6a807e..a7f56bac7 100644 Binary files a/testfiles/Unicode-tests-preserved-NF.zip and b/testfiles/Unicode-tests-preserved-NF.zip differ