I had this problem and went through the tedious exercise of understanding unicode, utf-8 etc all over again.
Basically the developer of LWP has enforced that strings sent to HTTP::Message - and therefore all the higher functions such as parse to be octet based - as it is in the natural environment of the web.
So this means that generating raw html strings in perl and expecting HTTP::Response parsing to work will fail (because Perl uses native utf8 and the module doesn't.
This is pretty annoying I know as you assume you shouldn't have to encode perl strings internally - but thats how it is.
The easy fix is to force your homemade html strings to be byte based thus:
use Encode;
use HTTP::Response;
my $internal_html = my_html_generation_function();
my $enc_html = encode("iso-8859-1",$internal_html); #for the respons
+e object to manage in octets;
my $response = HTTP::Response->parse($enc_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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.