Skip Menu |

This queue is for tickets about the Encode CPAN distribution.

Report information
The Basics
Id: 56443
Status: resolved
Priority: 0/
Queue: Encode

People
Owner: Nobody in particular
Requestors: yyang [...] proofpoint.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.39
Fixed in: (no value)



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 "+" ) {
Your patch is in now. Thank you. Dan the Encode Maintainer On Fri Apr 09 17:22:43 2010, yyang wrote: Show quoted text
> 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 "+" ) {