Perl:为什么 Term::Readline 会破坏 STDIN/STDOUT?
如果我创建新的 Term::Readline 对象(并传递 binmoded STDIN 和 STDOUT),输入和输出将被模拟。示例:
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use utf8::all;
use Term::ReadLine;
my $X = <>;
chomp $X;
say "õ $X";
my $term = new Term::ReadLine ('test', \*STDIN, \*STDOUT);
say "õ $X";
$X = <>;
chomp $X;
say "õ $X";
__END__
got:
õ
õ õ
� �
õ
� õ
如果我输入拉丁语 1 中不存在的字符,我会收到“宽字符”警告,并且输出更好,但仍然不正确:
ž
õ ž
Wide character in print at db.test.pl line 20, <> line 1.
õ ž
ž
� ž
使用 Term::Readline 时如何正确设置 IO?
If I create new Term::Readline object (and pass binmoded STDIN and STDOUT), input and output get mocked. Example:
#!/usr/bin/env perl
use strict;
use warnings;
use 5.010;
use utf8::all;
use Term::ReadLine;
my $X = <>;
chomp $X;
say "õ $X";
my $term = new Term::ReadLine ('test', \*STDIN, \*STDOUT);
say "õ $X";
$X = <>;
chomp $X;
say "õ $X";
__END__
got:
õ
õ õ
� �
õ
� õ
If i input characters, which are not present in Latin 1, i get "Wide character" warning and output is better, but still not correct:
ž
õ ž
Wide character in print at db.test.pl line 20, <> line 1.
õ ž
ž
� ž
How properly set IO when using Term::Readline?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
构造函数将“stdio”层添加到需要删除的流中。请参阅 PerlIO 中的
:pop
。The constructor adds the 'stdio' layer to the streams which you need to remove. See
:pop
in PerlIO.