Apr 25, 2017, 8:20 AM
Post #1 of 4
I have a perl script that receives binary data from another script (PDF file). The question is how to transfer this data to another script. I try so.
How to correctly return a PDF file in response to a query?
Data comes in utf8 encoding. I tried to recode
$con = $response->content;
open (OUT2,">11.txt") || die;
print OUT2 $con;
print "Content-Type: application/octet-stream;;\n";
print "Content-Length: ".length($con)."\n";
print "Content-Disposition: attachment; filename=FILE.pdf\n\n";
Comes already in ANSI but the characters are not the ones. And if you save the string $ con in perle to a file, you get everything in the right format. Tell me what I'm doing wrong?
Encode::from_to($con, 'utf-8', 'windows-1251');
print encode("cp1251", decode("utf8", $con));