Skip to content

Commit

Permalink
Looking at #474
Browse files Browse the repository at this point in the history
  • Loading branch information
plk committed Apr 14, 2024
1 parent 84f49a1 commit c517652
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
9 changes: 9 additions & 0 deletions bin/biber
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use Encode;
use File::Spec;
use Pod::Usage;
use List::AllUtils qw( first );
use Unicode::Normalize qw(NFC);

use Getopt::Long qw/:config no_ignore_case/;
my $opts = {};
Expand Down Expand Up @@ -341,6 +342,14 @@ $logfile->info("=== $time_string");

my $bcf = Biber::Config->getoption('bcf');

# Determine the input Unicode form so we can make sure output filenames are the
# same format
if ($bcf eq NFC($bcf)) {
Biber::Config->setoption('UFORM', 'NFC');
} else {
Biber::Config->setoption('UFORM', 'NFD');
}

if (Biber::Config->getoption('output_file')) {
$outfile = Biber::Config->getoption('output_file')
}
Expand Down
9 changes: 6 additions & 3 deletions lib/Biber/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use Log::Log4perl::Appender::Screen;
use Log::Log4perl::Appender::File;
use Log::Log4perl::Layout::SimpleLayout;
use Log::Log4perl::Layout::PatternLayout;
use Unicode::Normalize;
use Unicode::Normalize qw(normalize NFC NFD);
use parent qw(Class::Accessor);
__PACKAGE__->follow_best_practice;

Expand Down Expand Up @@ -224,8 +224,11 @@ sub _initopts {
}
}

# Sanitse log file name to NFC
$biberlog = NFC($biberlog);
# Sanitise log file name to the same as the input .bcf
if ($biberlog) {
$biberlog = normalize('NFD', $biberlog);
# $biberlog = normalize(Biber::Config->getoption('UFORM'), $biberlog);
}

# cache meta markers since they are referenced in the oft-called _get_handler
$CONFIG_META_MARKERS{annotation} = quotemeta(Biber::Config->getoption('annotation_marker'));
Expand Down
1 change: 1 addition & 0 deletions lib/Biber/Constants.pm
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ our $CONFIG_DEFAULT_BIBER = {
xdatasep => { content => '-' },
xnamesep => { content => '=' },
xsvsep => { content => q/\s*,\s*/ },
UFORM => { content => 'NFC' }
};

# Set up some re-usable CSV parsers here for efficiency reasons
Expand Down
10 changes: 8 additions & 2 deletions lib/Biber/Output/base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use IO::File;
use Text::Wrap;
$Text::Wrap::columns = 80;
use Log::Log4perl qw( :no_extra_logdie_message );
use Unicode::Normalize;
use Unicode::Normalize qw(normalize NFC NFD);
my $logger = Log::Log4perl::get_logger('main');

=encoding utf-8
Expand Down Expand Up @@ -60,7 +60,13 @@ sub set_output_target_file {
if (my $enc = Biber::Config->getoption('output_encoding')) {
$enc_out = ":encoding($enc)";
}
return IO::File->new($file, ">$enc_out");

if (ref($file) eq 'SCALAR') {
return IO::File->new($file, ">$enc_out");
}
else {
return IO::File->new(normalize(Biber::Config->getoption('UFORM'), $file), ">$enc_out");
}
}

=head2 get_output_target_file
Expand Down

0 comments on commit c517652

Please sign in to comment.