Term :: ReadLine:返回readline的值

时间:2014-07-02 15:38:12

标签: perl encoding terminal console readline

要在以下脚本中获得正确的输出,我必须解码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 );

0 个答案:

没有答案