Term :: Readline:encoding-question [英] Term::Readline: encoding-question

查看:129
本文介绍了Term :: Readline:encoding-question的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我进入Müller时,屏幕上出现M ?? ller。如何解决这个问题?

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


推荐答案

应用:utf8 图层到文件句柄 STDIN STDOUT ,并将它们作为参数传递给 Term :: ReadLine-> new()

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 );

这篇关于Term :: Readline:encoding-question的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆