Dear Monks, My gods are in disagreement, who can I trust? The Encode page http://perldoc.perl.org/Encode.html#The-UTF8-flag says:
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 ---------------------------------------------
Yet at the altar of Perl 5.10.0 and Perl 5.8:
#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";
Produces:
${^UNICODE}=63 a= b= a=1 b=1
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?

Bryce Nesbitt, Berkeley Electronic Press, Berkeley CA


In reply to Why is utf8 flag set after Encode::decode of pure ASCII? by brycen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.