diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-15 09:42:25 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-15 09:42:25 -0700 |
commit | 18b4522261c5899403f701212b1be91b837df038 (patch) | |
tree | 2ec7350ec45140ea935eb2faee01fb139d9cd93c /perl5 | |
parent | f0d2e7b1c5457af2918c35255854c6d105832c64 (diff) | |
download | dotfiles-18b4522261c5899403f701212b1be91b837df038.tar.gz |
_sysptycap_tty: decode using locale's charset if possible
Diffstat (limited to 'perl5')
-rw-r--r-- | perl5/Local/Interactive.pm | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/perl5/Local/Interactive.pm b/perl5/Local/Interactive.pm index 58d09d02..4ac8e92f 100644 --- a/perl5/Local/Interactive.pm +++ b/perl5/Local/Interactive.pm @@ -26,6 +26,8 @@ use Term::ANSIColor; use Local::ScriptStatus; use Sys::Hostname; use POSIX ":sys_wait_h"; +use I18N::Langinfo qw(langinfo CODESET); +use Encode "decode"; # Quoting perldoc perlmodlib: "As a general rule, if the module is # trying to be object oriented then export nothing. If it's just a @@ -239,7 +241,11 @@ sub _sysptycap_tty { } $slave->close; exit 2 if $interrupted; - # TODO decode $output according to the locale's charset + + # since sysread was raw bytes, want to decode if possible + my $codeset = eval { langinfo CODESET }; + $output = decode $codeset, $output if $codeset; + return { exit => $? >> 8, output => $output }; } |