Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Can't tell if UTF-8... or just binary...

by ikegami (Pope)
on Aug 23, 2011 at 19:30 UTC ( #921975=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $ perl -MDevel::Peek -e'$_="\x{00C9}ric"; Dump($_);'
      FLAGS = (POK,pPOK)
    ...
    $ perl -MDevel::Peek -e'$_=pack("N", 0xC9726963); Dump($_);'
      FLAGS = (POK,pPOK)
      PV = 0xa16b2d8 "\311ric"\0      # Binary
    
  2. or download this
    my $is_utf8 = eval {
       decode('UTF-8', $bytes, Encode::FB_CROAK|Encode::LEAVE_SRC);
       1
    };
    
  3. or download this
    $ perl -MDevel::Peek -e'$_="ABCD"; Dump($_);'
      FLAGS = (POK,pPOK)
    ...
    $ perl -MDevel::Peek -e'$_=pack("N", 0x41424344); Dump($_);'
      FLAGS = (POK,pPOK)
      PV = 0x9e0a2c8 "ABCD"\0         # Binary
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://921975]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2021-10-20 00:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (78 votes). Check out past polls.

    Notices?