当我进入“Müller”时,屏幕上出现“M ?? ller”。我怎么能解决这个问题?
#!/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
答案 0 :(得分:7)
将:utf8
图层应用于文件句柄STDIN
和STDOUT
,并将其作为参数传递给Term::ReadLine->new()
:
binmode STDIN, ':utf8';
binmode STDOUT, ':utf8';
my $term = Term::ReadLine->new( 'dummy', \*STDIN, \*STDOUT );