Greetings perl monks,

I'm trying to send packed data through RabbitMQ using Net::RabbitMQ, and am running into problems with the data being munged on the way into the library.

I'm packing a couple strings using  pack("n/an/a", $str1, $str2). If I hexdump the buffer it looks as I expect:

03 B0 2D 2D 2D 0A 43 4F - 4E 54 45 4E 54 5F 4C 45 ..---.CONTENT_LE

All is good, 03 B0 == 944 == the length of $str1. However, when I invoke the RabbitMQ method Net::RabbitMQ::publish, an XS method which I have hacked to print the first few bytes of the input data, I find it has been changed to 03 c2 b0 2d. This feels like a charset manipulation is going on.

If I add  use bytes to the module invoking the call, all is well. However, the documentation for use bytes strongly discourages its use for anything other than documentation. It is unclear to me exactly how to properly proceed.

This is with perl 5.12.2 on 64-bit intel.

Thank you for your wisdom,

--bob


In reply to use bytes vs packed data by RDOlson

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.