perlquestion
friedo
<p>Greetings!</p>
<p>I've run into some confusion with an encoding issue. I'm fetching some files with Mechanize (PDF's in particular) and passing them in-memory to another function, in this case Compress::Zlib::memGzip.
<c>
use Compress::Zlib;
...
$mech->get( $pdf_url );
my $compressed = Compress::Zlib::memGzip( $mech->content );
</c>
I'm getting the dreaded "wide character in memGzip" warning when I do this, which, if my understanding is correct, tells me a few things:
<ul>
<li>Mechanize (or somebody) is storing the PDF data as a character string</li>
<li>Since PDF is a byte format, I really don't want it in a character string</li>
<li><c>memGzip</c> doesn't want a character string either</li>
<li>I have to somehow make it not a character string</li>
</ul>
And that's where I'm lost. I know how to convert character data to various encodings using Encode, and how to set binmode on a filehandle, but I can't seem to work out how to get that PDF data in the format it should be in.
</p>
<p>
Mech does have a <c>save_content</c> method which promises to save the content in binary mode if it's not a <c>text/*</c> MIME type (and I've checked that the MIME type is correct.) However, I'd hate to have to dump the content to a temp file just to read it in again.
</p>