Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to interpret characters in Devel::Peek CUR

by kcott (Archbishop)
on Jun 09, 2020 at 05:37 UTC ( [id://11117851]=note: print w/replies, xml ) Need Help??


in reply to How to interpret characters in Devel::Peek CUR

G'day ait,

The characters, “ and ”, are U+201C and U+201D. The numbers \342\200\234 and \342\200\235 are the octal values of the bytes that make up those characters.

You can break those characters into their constituent bytes and check the octal values like this:

$ perl -C -E ' my $x = "\x{201c}S\x{201d}"; say $x; { use bytes; printf "%vo\n", $x; } ' “S” 342.200.234.123.342.200.235

See also: bytes noting the emboldened warning; and the vector flag information in sprintf.

— Ken

Replies are listed 'Best First'.
Re^2: How to interpret characters in Devel::Peek CUR
by haukex (Archbishop) on Jun 09, 2020 at 07:59 UTC
    The characters, “ and ”, are U+201C and U+201D. The numbers \342\200\234 and \342\200\235 are the octal values of the bytes that make up those characters.

    Sorry, but this leaves out a very important bit: these are the bytes that make up the characters when encoded as UTF-8.

      What he said :).

      In EBCDIC land you'd get something completely different:

      $ perl -MData::Peek -wE'say $^O;DPeek ("\x{201c}"); DPeek ("\x{201d}") +' os390 PV("\312\101\160"\0) [UTF8 "\x{201c}"] PV("\312\101\161"\0) [UTF8 "\x{201d}"]

      Enjoy, Have FUN! H.Merijn
Re^2: How to interpret characters in Devel::Peek CUR
by ait (Hermit) on Jun 11, 2020 at 17:00 UTC

    Wow, thanks for the use bytes trick! Curiously I use Perl for another project where I translate REST into Modbus and I use a lot of pack and unpack, but I never used bytes before. Thanks!!

Re^2: How to interpret characters in Devel::Peek CUR
by ait (Hermit) on Jun 16, 2020 at 15:07 UTC

    Thank you kcott ! The bytes nugget was a great tip!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-25 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found