Set STDERR, STDOUT, log file and config file binmode to UTF8

In addition use three argument open for opening the log file instead of
combining the mode and filename together.
pull/235/head
Samantha McVey 2018-03-28 12:16:43 -07:00
parent 1d0d57ffac
commit 68164d21e5
No known key found for this signature in database
GPG Key ID: A68DF012C3881D62
1 changed files with 7 additions and 1 deletions

8
btrbk
View File

@ -27,6 +27,8 @@
use strict;
use warnings FATAL => qw( all ), NONFATAL => qw( deprecated );
binmode STDOUT, ':encoding(UTF-8)';
binmode STDERR, ':encoding(UTF-8)';
use Carp qw(confess);
use Getopt::Long qw(GetOptions);
@ -417,7 +419,9 @@ sub init_transaction_log($$)
my $file = shift;
my $config_syslog_facility = shift;
if(defined($file) && (not $dryrun)) {
if(open($tlog_fh, ">> $file")) {
if(open($tlog_fh, '>>', $file)) {
binmode $tlog_fh, ':encoding(UTF-8)';
# print headers (disabled)
# print_formatted("transaction", [ ], output_format => "tlog", outfile => $tlog_fh);
INFO "Using transaction log: $file";
@ -3535,6 +3539,8 @@ sub parse_config(@)
INFO "Using configuration: $file";
open(FILE, '<', $file) or die $!;
binmode FILE, ':encoding(UTF-8)';
while (<FILE>) {
chomp;
s/#.*//; # remove comments