From: Jarkko Hietaniemi Date: Sun, 16 Mar 2003 15:41:44 +0000 (+0000) Subject: Fix for [perl #21479] Term::ReadLine(::Stub) doesn't set UTF-8 flag. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2499d3299d5b988dc734ee240003b6eb71752236;p=p5sagit%2Fp5-mst-13.2.git Fix for [perl #21479] Term::ReadLine(::Stub) doesn't set UTF-8 flag. Should work both for PERL_UNICODE/-C and use encoding 'foo'; p4raw-id: //depot/perl@18994 --- diff --git a/lib/Term/ReadLine.pm b/lib/Term/ReadLine.pm index 238e9fd..a4de5fc 100644 --- a/lib/Term/ReadLine.pm +++ b/lib/Term/ReadLine.pm @@ -184,6 +184,8 @@ $DB::emacs = $DB::emacs; # To peacify -w our @rl_term_set; *rl_term_set = \@Term::ReadLine::TermCap::rl_term_set; +sub PERL_UNICODE_STDIN () { 0x0001 } + sub ReadLine {'Term::ReadLine::Stub'} sub readline { my $self = shift; @@ -196,6 +198,8 @@ sub readline { #$str = scalar <$in>; $str = $self->get_line; $str =~ s/^\s*\Q$prompt\E// if ($^O eq 'MacOS'); + utf8::upgrade($str) + if ${^UNICODE} & PERL_UNICODE_STDIN || defined ${^ENCODING}; print $out $rl_term_set[3]; # bug in 5.000: chomping empty string creats length -1: chomp $str if defined $str;