4

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
sid_com
  • 24,137
  • 26
  • 96
  • 187

1 Answers1

7

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 );
Alan Haggai Alavi
  • 72,802
  • 19
  • 102
  • 127