From: b Date: Wed, 14 Jun 2023 23:15:22 +0000 (+0000) Subject: exec with encoding X-Git-Tag: v1.0.11 X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=refs%2Ftags%2Fv1.0.11;p=botm%2Fcommon-perl exec with encoding --- diff --git a/botm_common.pm b/botm_common.pm index 0d6b4dd..0e8c405 100644 --- a/botm_common.pm +++ b/botm_common.pm @@ -24,21 +24,19 @@ use Encode::Locale; use Encode ('encode', 'decode'); use Exporter; -use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); -# vX.Y.Z: X YYYZZZ -$VERSION = 1.000010; -@ISA = qw(Exporter); -@EXPORT = (); -@EXPORT_OK = ( +our $VERSION = '1.0.11'; +our @ISA = qw(Exporter); +our @EXPORT = (); +our @EXPORT_OK = ( 'read_data_file', 'write_data_file', 'url_encode', 'url_decode', 'url_query_encode', 'url_query_decode', 'split_url', 'join_url', 'merge_url', 'html_entity_encode_dec', 'html_entity_encode_hex', 'html_entity_encode_name', 'html_entity_decode', - 'join_path', 'make_temp_path' + 'join_path', 'make_temp_path', + 'system_encoded', 'exec_encoded' ); -%EXPORT_TAGS = (); @@ -94,6 +92,32 @@ sub make_temp_path { return join_path('/', $dir, $filename); } +sub system_encoded { + (my $cmd, my @arg) = @_; + my @newarg; + + my $newcmd = encode('locale_fs', $cmd); + + foreach my $a (@arg) { + push @newarg, encode('locale', $a); + } + + return system $newcmd, @newarg; +} + +sub exec_encoded { + (my $cmd, my @arg) = @_; + my @newarg; + + my $newcmd = encode('locale_fs', $cmd); + + foreach my $a (@arg) { + push @newarg, encode('locale', $a); + } + + return exec $newcmd, @newarg; +} + ##################