Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-19 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found