because you cannot "decode()" a string into perl-internal utf8 if it is already flagged as being perl-internal utf8.
Not true. It would be a bug if the internal representation mattered (by definition of internal), and the following demonstrates that it doesn't.
use strict; use warnings; use Encode qw( encode decode ); sub test { my ($enc, $orig) = @_; my $bin = encode($enc, $orig); utf8::downgrade my $bin_dn = $bin; # UTF8=0 utf8::upgrade my $bin_up = $bin; # UTF8=1 my $txt_dn = decode($enc, $bin_dn); my $txt_up = decode($enc, $bin_up); printf("%-11s %d %d\n", "$enc:", $txt_dn eq $orig ? 1 : 0, $txt_up eq $orig ? 1 : 0, ); } test('iso-8859-1', "A\x{E2}"); test('UTF-8', "A\x{E2}\x{2660}"); test('UTF-16le', "A\x{E2}\x{2660}");
iso-8859-1: 1 1 UTF-8: 1 1 UTF-16le: 1 1
I think you were trying to say that it makes no sense to decode something that's already been decoded, but that's got nothing to do with whether it's a "perl-internal utf8" buffer or not.
In reply to Re^2: question about Encode::decode('iso-8859-1', ...)
by ikegami
in thread question about Encode::decode('iso-8859-1', ...)
by perl5ever
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |