From b5d5ee3a8838f125f57231060fef7a7cb8e4b2cb Mon Sep 17 00:00:00 2001 From: b Date: Tue, 13 Jun 2023 23:56:28 +0000 Subject: [PATCH] IO encoding --- botm-common | 2 +- sendpost.1.pl | 22 ++++++++-------------- settings-debug.txt | 5 +---- settings-release.txt | 5 +---- settings.txt | 5 +---- 5 files changed, 12 insertions(+), 27 deletions(-) diff --git a/botm-common b/botm-common index c484395..b443d98 160000 --- a/botm-common +++ b/botm-common @@ -1 +1 @@ -Subproject commit c4843959c15d793dca50517c28dee25ddecbe275 +Subproject commit b443d985fea32c8971cf6ffe5e2821119598d823 diff --git a/sendpost.1.pl b/sendpost.1.pl index c857849..5108218 100644 --- a/sendpost.1.pl +++ b/sendpost.1.pl @@ -18,7 +18,8 @@ use strict; use utf8; use Getopt::Long; -use Encode qw(encode decode); +use Encode::Locale ('decode_argv'); +use Encode ('encode', 'decode'); ###PERL_LIB: use lib '/botm/lib/post'; use botm_common ( @@ -27,10 +28,7 @@ use botm_common ( 'make_temp_path' ); -###PERL_ENCODING_FILE_IN: use constant ENCODING_FILE_IN => 'UTF-8'; -###PERL_ENCODING_FILE_OUT: use constant ENCODING_FILE_OUT => 'utf8'; -###PERL_ENCODING_STD_IN: use constant ENCODING_STD_IN => 'UTF-8'; -###PERL_ENCODING_STD_OUT: use constant ENCODING_STD_OUT => 'utf8'; +###PERL_ENCODING_FILE: use constant ENCODING_FILE => 'UTF-8'; ###PERL_DEFAULT_PASSWORD: use constant DEFAULT_PASSWORD => 'password'; ###PERL_DEFAULT_SUBJECT: use constant DEFAULT_SUBJECT => 'Re: 1190: "Time"'; @@ -67,17 +65,13 @@ use constant HELP_TEXT => "\n". " -h, --help\n"; -binmode STDIN, ':encoding('.ENCODING_STD_IN.')'; -# binmode ARGV, ':encoding('.ENCODING_STD_IN.')'; # not working -binmode STDOUT, ':encoding('.ENCODING_STD_OUT.')'; -binmode STDERR, ':encoding('.ENCODING_STD_OUT.')'; +binmode STDIN, ':encoding(console_in)'; +binmode STDOUT, ':encoding(console_out)'; +binmode STDERR, ':encoding(console_out)'; +decode_argv(); my %options = {}; -foreach my $arg (@ARGV) { - $arg = decode(ENCODING_STD_IN, $arg); -} - Getopt::Long::Configure('bundling'); GetOptions ( 'username|l=s' => \$options{'username'}, @@ -124,7 +118,7 @@ if ((scalar @ARGV) == 0) { foreach my $arg (@ARGV) { # print "\nFILE $arg\n"; - my %data = read_data_file($arg, ENCODING_FILE_IN, $options{'data-only'}); + my %data = read_data_file($arg, ENCODING_FILE, $options{'data-only'}); # foreach my $ind (keys %data) { # print $ind.'='.$data{$ind}."\n"; # } diff --git a/settings-debug.txt b/settings-debug.txt index 42b9345..bc2ba56 100644 --- a/settings-debug.txt +++ b/settings-debug.txt @@ -13,10 +13,7 @@ tmp_path: /botm/tmp/test-post mirror_url: http://1190.botcastle1b/ott -encoding_file_in: UTF-8 -encoding_file_out: utf8 -encoding_std_in: UTF-8 -encoding_std_out: utf8 +encoding_file: UTF-8 default_subject: Re: 1190: "Time" default_username: _ diff --git a/settings-release.txt b/settings-release.txt index cfdb6cf..aeeb7fe 100644 --- a/settings-release.txt +++ b/settings-release.txt @@ -13,10 +13,7 @@ tmp_path: /botm/tmp/post mirror_url: https://1190.bicyclesonthemoon.info/ott -encoding_file_in: UTF-8 -encoding_file_out: utf8 -encoding_std_in: UTF-8 -encoding_std_out: utf8 +encoding_file: UTF-8 default_subject: Re: 1190: "Time" default_username: _ diff --git a/settings.txt b/settings.txt index 42c656a..8cd1625 100644 --- a/settings.txt +++ b/settings.txt @@ -38,10 +38,7 @@ MAKE_TMP_PATH = TMP_PATH = $tmp_path PERL_DEFAULT_PASSWORD = @_PERL_CONSTANT_STR( DEFAULT_PASSWORD , $default_password) PERL_DEFAULT_SUBJECT = @_PERL_CONSTANT_STR( DEFAULT_SUBJECT , $default_subject) PERL_DEFAULT_USERNAME = @_PERL_CONSTANT_STR( DEFAULT_USERNAME , $default_username) -PERL_ENCODING_FILE_IN = @_PERL_CONSTANT_STR( ENCODING_FILE_IN , $encoding_file_in) -PERL_ENCODING_FILE_OUT = @_PERL_CONSTANT_STR( ENCODING_FILE_OUT, $encoding_file_out) -PERL_ENCODING_STD_IN = @_PERL_CONSTANT_STR( ENCODING_STD_IN , $encoding_std_in) -PERL_ENCODING_STD_OUT = @_PERL_CONSTANT_STR( ENCODING_STD_OUT , $encoding_std_out) +PERL_ENCODING_FILE = @_PERL_CONSTANT_STR( ENCODING_FILE , $encoding_file) PERL_MIRROR_URL = @_PERL_CONSTANT_STR( MIRROR_URL , $mirror_url) PERL_TMP_PATH = @_PERL_CONSTANT_STR( TMP_PATH , $tmp_path) -- 2.30.2