I am posting again for a problem I didn't quite get an answer to. I seem to have upset someone on this board since I guess I myself am not entirely sure how to define the unexpected output I am experiencing and our discussions spun into many directions. I know this is Perl-specific, this much I know. Here is the GENERAL overview of what I am trying to do:
OVERVIEW
1) C program calls a Perl script with "popen"
2) Said Perl script sends an HTTP GET request to a webserver
3) Webserver returns a plain text file to Perl script
,br>
4) Perl script prints contents returned from webserver, to STDOUT
5) Calling C program captures the output from STDOUT
THINGS I DO KNOW:
a) The webserver is functioning properly and I have explicitly encoded the content to be "text/plain". I have confirmed this by printing out the response header in Perl
b) The C program is properly calling the script. I tested this with a simple print command from within the Perl script; When I call the C program, it is able to capture the print command output from the script (e.g. if I issue "print $var" from Perl, I am able to get that INTO my C program).
PROBLEM
My C program cannot capture the output from my Perl script WHEN I am using an HTTP GET request. In other words, if I put the following lines in my Perl script:
my $variable = "Hello";
print $variable;
My C program will capture "Hello" and print it out if I want. But if I use the following lines, assuming I set the contents returned to "Hello" from the webserver:
my $ua = new LWP::UserAgent;
my $response = $ua->get('http://SOMEURL');
my $decodedContent = $response->decoded_content(charset=>'none');
print $decodedContent;
It prints nothing/blank. I confirmed this by even doing the following:
my $ua = new LWP::UserAgent;
my $response = $ua->get('http://SOMEURL');
my $decodedContent = $response->decoded_content(charset=>'none');
print "HELLO-$decodedContent-HELLO";
....and I my C program prints out "HELLO--HELLO" with nothing in between as HAS BEEN CODED. I tried printing out the above $decodedContent variable to a file. With that I see it, except it obviously is encoded UTF16BE because of the "@^H@^e@^l@^l@^l@^o" characters I see. I don't get this if I print a regular string variable that I created, to file.
I am assuming this is some kind of character encoding problem. HELP!!!