brycen has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
My gods are in disagreement, who can I trust? The Encode page http://perldoc.perl.org/Encode.html#The-UTF8-flag says:
Yet at the altar of Perl 5.10.0 and Perl 5.8: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 ---------------------------------------------
Produces:#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";
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?${^UNICODE}=63 a= b= a=1 b=1
Bryce Nesbitt, Berkeley Electronic Press, Berkeley CA
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Why is utf8 flag set after Encode::decode of pure ASCII?
by moritz (Cardinal) on Mar 29, 2010 at 18:34 UTC | |
by brycen (Monk) on Mar 30, 2010 at 18:32 UTC | |
by Joost (Canon) on Apr 01, 2010 at 00:36 UTC | |
by creamygoodness (Curate) on Mar 30, 2010 at 19:00 UTC | |
Re: Why is utf8 flag set after Encode::decode of pure ASCII?
by ikegami (Patriarch) on Mar 29, 2010 at 17:14 UTC | |
Re: Why is utf8 flag set after Encode::decode of pure ASCII?
by creamygoodness (Curate) on Mar 29, 2010 at 19:02 UTC | |
Re: Why is utf8 flag set after Encode::decode of pure ASCII?
by brycen (Monk) on Mar 30, 2010 at 01:18 UTC | |
Re: Why is utf8 flag set after Encode::decode of pure ASCII?
by mrajcok (Initiate) on Mar 30, 2010 at 19:26 UTC |
Back to
Seekers of Perl Wisdom