in reply to RT::Client turns occasional binary characters in to wide characters

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
  • Comment on Re: RT::Client turns occasional binary characters in to wide characters
  • Download Code

Replies are listed 'Best First'.
Re^2: RT::Client turns occasional binary characters in to wide characters
by wardmw (Acolyte) on Oct 03, 2018 at 10:50 UTC
    Thanks for responding Bill. I haven't tried unpack on the string yet, I will give that a go and see what it returns.

    You are right that the address of the following bytes is correct, in the Perl hexdump output it is showing four hex characters whereas the Linux hexdump output only shows two, so something is translating the code internally, as @Veltro suggests below.