I do not think that there is anything wrong with your string, only with the utility you use to display it. I have recreated your file (named it 1223420.png), displayed it with xxd to show I got it right (ignore windows clrl at end), read that file into a string and converted the first 16 characters of that string to hex with unpack. The content of the string is correct.
$xxd 1223420.png 00000000: 504b 0304 1400 0900 0800 678d 2546 0000 PK........g.%F.. 00000010: 0000 0000 0000 0000 0000 1c00 0000 7363 ..............sc 00000020: 7265 656e 7368 6f74 2d31 3732 2032 3120 reenshot-172 21 00000030: 3234 3220 3634 2e7a 6970 329e 8afc b515 242 64.zip2..... 00000040: 0d0a .. $type 1223420.pl use strict; use warnings; my $string = <>; print unpack( 'H32', $string ); $perl 1223420.pl 1223420.png 504b0304140009000800678d25460000
Also note in you output, that although the offending bytes are printed as four hex characters, the address of the following bytes is correct.
Bill

In reply to Re: RT::Client turns occasional binary characters in to wide characters by BillKSmith
in thread RT::Client turns occasional binary characters in to wide characters by wardmw

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.