Bytes from a string

Carl Mäsak cmasak at gmail.com
Mon Mar 23 12:52:49 UTC 2009


Hello,

Wanting to escape URIs in our Web.pm project, I would like to
implement unpack("H*", $str) in Rakudo:

  say unpack("H*", "☺"); # should print 'e298ba'

What facilities exist in Parrot (or, more precisely, PIR), to extract
the list of bytes making up a string? I'd need something like
to_bytes.

Bonus points for answering with working PIR code, of course.

(I asked this question on IRC last week but didn't get a conclusive
answer: <http://irclog.perlgeek.de/parrot/2009-03-17#i_994363>)

// Carl


More information about the parrot-dev mailing list