开发者

Term::Readline: encoding-question

开发者 https://www.devze.com 2023-02-09 18:06 出处:网络
When I enter \"Müller\", on the screen appears \"M??ller\". How could I fix this? #!/usr/bin/env perl

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

精彩评论

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