要在以下脚本中获得正确的输出,我必须解码readline
返回的值。
是否可以安全地假设所有Term::ReadLine后端都需要解码readline
的返回值?
#!/usr/bin/env perl
use warnings;
use strict;
use 5.10.0;
use Encode;
use Encode::Locale;
use Term::ReadLine;
binmode STDOUT, ':encoding(console_out)';
my $term = Term::ReadLine->new( 'readline' );
say $term->ReadLine; # Term::ReadLine::Gnu
my $line = $term->readline( ':' );
say decode( 'console_in', $line );