perlquestion
brycen
Dear Monks,
My gods are in disagreement, who can I trust? The Encode page <a href="http://perldoc.perl.org/Encode.html#The-UTF8-flag">http://perldoc.perl.org/Encode.html#The-UTF8-flag</a> says:
<blockquote>
<code>
After $utf8 = decode('foo', $octet); ,
When $octet is... The UTF8 flag in $utf8 is
---------------------------------------------
In ASCII only (or EBCDIC only) OFF
In ISO-8859-1 ON
In any other Encoding ON
---------------------------------------------
</code>
</blockquote>
Yet at the altar of Perl 5.10.0 and Perl 5.8:
<blockquote>
<code>
#use utf8;
#use encoding 'iso-8859-1';
#use encoding 'utf-8-strict';
#use encoding::warnings; #check for implicit upgrade
use Encode;
print '${^UNICODE}='.${^UNICODE}."\n\n";
$a = "face";
$b = "not_a_face=\x{e2}\x{98}\x{ba}";
print "a=",Encode::is_utf8($a)," b=",Encode::is_utf8($b),"\n\n";
$a=Encode::decode('iso-8859-1',$a);
$b=Encode::decode('iso-8859-1',$b);
print "a=",Encode::is_utf8($a)," b=",Encode::is_utf8($b),"\n\n";
</code>
</blockquote>
Produces:
<blockquote>
<code>
${^UNICODE}=63
a= b=
a=1 b=1
</code>
</blockquote>
Showing that a pure ASCII string has the utf8 flag set. My faith in Perl Unicode is tested. Monks can you help me see the light?
<blockquote>
<p><a href="http://www.obviously.com/">Bryce Nesbitt</a>, <a href="http://www.bepress.com/">Berkeley Electronic Press</a>, Berkeley CA
</blockquote>