summaryrefslogtreecommitdiff
path: root/lib/Term
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2003-03-16 17:41:42 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2003-03-16 17:41:42 +0000
commit11412ee612ee855f6157e78034024e8f5e3ba052 (patch)
tree4528b0d0dc9f0efa9fa952f807b3f56046745cbd /lib/Term
parent5e43f4674257b58e1586fd5e88cdab2ae2f833ee (diff)
downloadperl-11412ee612ee855f6157e78034024e8f5e3ba052.tar.gz
Turn on UTF-8 flag only if the $str is valid utf8
(pointed out by Dan Kogai). p4raw-id: //depot/perl@18996
Diffstat (limited to 'lib/Term')
-rw-r--r--lib/Term/ReadLine.pm5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Term/ReadLine.pm b/lib/Term/ReadLine.pm
index a4de5fcc51..8cb6ab3f2b 100644
--- a/lib/Term/ReadLine.pm
+++ b/lib/Term/ReadLine.pm
@@ -199,7 +199,8 @@ sub readline {
$str = $self->get_line;
$str =~ s/^\s*\Q$prompt\E// if ($^O eq 'MacOS');
utf8::upgrade($str)
- if ${^UNICODE} & PERL_UNICODE_STDIN || defined ${^ENCODING};
+ if (${^UNICODE} & PERL_UNICODE_STDIN || defined ${^ENCODING}) &&
+ utf8::valid($str);
print $out $rl_term_set[3];
# bug in 5.000: chomping empty string creats length -1:
chomp $str if defined $str;
@@ -289,7 +290,7 @@ sub Features { \%features }
package Term::ReadLine; # So late to allow the above code be defined?
-our $VERSION = '1.00';
+our $VERSION = '1.01';
my ($which) = exists $ENV{PERL_RL} ? split /\s+/, $ENV{PERL_RL} : undef;
if ($which) {