Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Explicit charset confuses WWW::Mechanize and/or HTTP::Response

by Polyglot (Monk)
on May 16, 2009 at 14:49 UTC ( #764421=note: print w/ replies, xml ) Need Help??


in reply to Re: Explicit charset confuses WWW::Mechanize and/or HTTP::Response
in thread Explicit charset confuses WWW::Mechanize and/or HTTP::Response

I am curious about something. Have you tried more than one browser? If your situation is as it seems to me, you may see the proper character handling in Firefox, but IE will fail. (I've been there, done that.) Firefox will read the HTML headers, and respect them. IE does not. IE reads from the initial output to the browser in the content headers. Therefore, you need to do this in your code, before printing anything else to the browser:

print "Content-type: text/html; charset=utf-8\n\n"; #print CGI::header();

In other words, the charset must be made utf-8 right from the first exchange to the browser and forward.

Blessings,

Polyglot


Comment on Re^2: Explicit charset confuses WWW::Mechanize and/or HTTP::Response
Re^3: Explicit charset confuses WWW::Mechanize and/or HTTP::Response
by vitoco (Friar) on May 18, 2009 at 22:30 UTC

    Polyglot: in this case, IE displays the page OK, because the proper encoding is what HTTP header sais, as you predicted (the liar is the HTML header). I have not tried Firefox yet, but Opera also renders well those pages. I'm not sure if there is some automatic detection done by those browsers other than what is said both in the HTTP and/or HTML headers. Unfortunately, I can't touch the remote server's code, just live with it...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://764421]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2014-10-24 08:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (131 votes), past polls