开发者

Term::Readline: encoding-question

When I enter "Müller", on the screen appears "M??ller". How could I fix this?

#!/usr/bin/env perl
use warnings;
use 5.012;
use Term::ReadLine;

my $term = Term::ReadLine->new( 'dummy' );

my $con = $term->readline( ': ' );

say $con;

# On the screen:
# : M��ller                                                                                                                                      开发者_运维问答             
# Müller


Apply :utf8 layer to filehandles STDIN and STDOUT, and pass them as arguments to Term::ReadLine->new():

binmode STDIN,  ':utf8';
binmode STDOUT, ':utf8';

my $term = Term::ReadLine->new( 'dummy', \*STDIN, \*STDOUT );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜