Subject: | utf-8 flag is not turned off after calling Encode::encode('UTF-7', $string) to encode an ascii string |
If you try to encode a pure ASCII string into UTF-7, the UTF-8 flag is
not turned off.
Test case:
use strict;
use Test::More tests => 2;
use Encode qw(encode);
my $foo = "HelloWorld";
utf8::upgrade($foo);
ok Encode::is_utf8($foo);
my $octets = Encode::encode('UTF-7', $foo, 1);
ok !Encode::is_utf8($octets);
Proposed fix:
--- Unicode/UTF7.pm~ 2010-04-09 14:18:23.000000000 -0700
+++ Unicode/UTF7.pm 2010-04-09 14:13:49.000000000 -0700
@@ -35,7 +35,9 @@
my $bytes = '';
while ( pos($str) < $len ) {
if ( $str =~ /\G($re_asis+)/ogc ) {
- $bytes .= $1;
+ my $octets = $1;
+ utf8::downgrade($octets);
+ $bytes .= $octets;
}
elsif ( $str =~ /\G($re_encoded+)/ogsc ) {
if ( $1 eq "+" ) {